Re: [DISCUSS][PROPOSE] use of optional instead of null

2016-01-18 Thread John Burwell
Daan, The problem lies within Java itself and the decision not to allow for typed nulls. Therefore, writing safe code requires a certain degree null checking. There are also circumstances where a null is the correct representation. For example, there are optional numeric values who can only

Re: [DISCUSS][PROPOSE] use of optional instead of null

2016-01-17 Thread Daan Hoogland
Thanks John, I agree that the solution from your gist is a good one in several circumstances as well. It doesn't completely invalidate both other solutions completely, though. so now we have three 1. exceptions instead of nulls 2. optionals 3. nullables Not sure how to continue from here, except t

Re: [DISCUSS][PROPOSE] use of optional instead of null

2016-01-16 Thread John Burwell
Daan, I completely agree that returning null is bad. Not only does it yield a ton of useless null checks, it creates leaky abstractions by spreading the handling of the missing case out beyond the boundary of the class/subsystem. As a big proponent of the Null Object Pattern [1], I really wante

[DISCUSS][PROPOSE] use of optional instead of null

2015-11-17 Thread Daan Hoogland
LS, As a spin off from a discussion in a PR where it is no longer relevant I made another PR to show the principle of the use of Optionals[1] Miguel from Schuberg Philis has been proposing this as replacement of the bad practice of returning null i