java.util.Optional fields

Zhong Yu zhong.j.yu at gmail.com
Fri Sep 21 09:05:45 PDT 2012


On Fri, Sep 21, 2012 at 11:02 AM, Vitaly Davidovich <vitalyd at gmail.com> wrote:
> They're complementary, one doesn't replace the other.  If I'm looking at a
> diff of a change outside of IDE, I'd like to have more context.  I also may
> not want to pollute my code with @Nullable all over the place.

We will see the pollution of Optional all over the place. There will
be best practice polices scolding people into using it all over the
internet.

> Sent from my phone
> On Sep 21, 2012 11:55 AM, "Remi Forax" <forax at univ-mlv.fr> wrote:
>
>> On 09/21/2012 05:46 PM, Vitaly Davidovich wrote:
>> > The main benefit of Optional, to me, is that it clearly tells the caller
>> or
>> > receiver that this thing may be null; the conventional way is to document
>> > pre/post conditions, but developers are notorious for not reading docs.
>> > Returning/taking Optional is "in your face" - the fluent API is a
>> secondary
>> > convenience/benefit.
>>
>> Any decent IDEs (at least Eclipse and IDEA) understand @NonNull/@Nullable
>> and can be easily configured to not compile if you try to call a method on
>> something that is @Nullable.
>>
>> Are you suggesting that Optional is a runtime solution to a static
>> analysis problem ?
>>
>> Rémi
>>
>> >
>> > Sent from my phone
>> > On Sep 21, 2012 11:42 AM, "Zhong Yu" <zhong.j.yu at gmail.com> wrote:
>> >
>> >> aren't all reference types in Java "optional" already? If "fluent" API
>> >> is desired, is it possible to add methods to the null type?
>> >>
>> >> Zhong
>> >>
>> >>
>>
>>
>>
>


More information about the lambda-dev mailing list