[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-core-libs-dev
Subject: Code review: 7012540 (java.util.Objects.nonNull() incorrectly named)
From: matthias () mernst ! org (Matthias Ernst)
Date: 2011-01-29 11:13:25
Message-ID: AANLkTikPR+OOz+o2dPNzRgYF7aRZ_CmbmAMaoCKxxch= () mail ! gmail ! com
[Download RAW message or body]
On Thu, Jan 27, 2011 at 2:20 AM, Bob Lee <crazybob at crazybob.org> wrote:
> On Wed, Jan 26, 2011 at 3:44 PM, Joshua Bloch <jjb at google.com> wrote:
>>
>> I like the name?nonNull. ?All other things being equal, shorter is better.
>> ?I've used the name?nonNull for a few years, and it's feels right. To my
>> mind, requireNonNull?does a worse job of suggesting that the method returns
>> its argument.
>
> +1 for nonNull. While it's implemented as a method, I think of it more as a
> keyword-like modifier, in which case an adjective works better than a verb
> phrase.
> Bob
Couldn't agree more. I'm surprised no one has brought up the analogy
to type casts yet.
nonNull(o) is the equivalent of (String)o. It is a static assertion
that the static type system is too weak to express and that may fail
at runtime; programmers familiar with the Java language do not expect
(String)o to perform a value conversion either.
--
Matthias
nonNullOrBust.
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic