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
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
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