Optional doesn't get you out of null checks when you accept them as parameters 
though, does it? the logic to determine if something is or isn't there still 
has to be written if you have conditional logic based on the existance or 
non-existance of the value. If an Optional is still a reference type, you 
should still be able to send null through as a value as well, unless there's a 
compile time restriction and the compiler can always determine that a 
particular reference cannot be null.

What do Optional parameters give you vs method overloading or a builder pattern 
where you seed the required values via the initial builder constructor.

Dyana

On 2019/10/09 19:46:42, Jad Naous <jad.na...@imply.io> wrote: 
> Sir Tony Hoare on inventing null while working on ALGOL (from wikipedia
> below):
> 
> Speaking at a software conference called QCon London
> <https://qconlondon.com/> in 2009, he apologised for inventing the null
> reference <https://en.wikipedia.org/wiki/Null_pointer>:[23]
> <https://en.wikipedia.org/wiki/Tony_Hoare#cite_note-23>
> 
> I call it my billion-dollar mistake. It was the invention of the null
> reference in 1965. At that time, I was designing the first comprehensive
> type system for references in an object oriented language (ALGOL W
> <https://en.wikipedia.org/wiki/ALGOL_W>). My goal was to ensure that all
> use of references should be absolutely safe, with checking performed
> automatically by the compiler. But I couldn't resist the temptation to put
> in a null reference, simply because it was so easy to implement. This has
> led to innumerable errors, vulnerabilities, and system crashes, which have
> probably caused a billion dollars of pain and damage in the last forty
> years.
> 
> How about we stop passing nulls around as method arguments, field values,
> return values, etc and use Optional instead? Benefits:
> - No more NPEs
> - Better documentation through code
> - Less mistakes
> 
> I'm not suggesting we go rewrite everything, but rather just starting to
> only return and accept Optionals in methods/constructors/etc.
> 
> Jad.
> 
> -- 
> Jad Naous
> Imply | VP R&D
> 650-521-3425
> jad.na...@imply.io
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@druid.apache.org
For additional commands, e-mail: dev-h...@druid.apache.org

Reply via email to