News for hackers. Stuff that matters.
Re:My most common code review suggestions by Cthulhu_ on Thursday December 07, 2017 @07:36AM (#15869494)
In this case the most pragmatic thing to do is to ensure nothing in your application can ever be null - use asserts during development, empty lists, null objects, etc. Also never catch NPE's, if there is one after all those precautions, it's a developer error / bug and should be punished as such.

The problem with optionals - as Sonar will complain about - is that people will call `.get()` on an Optional without first checking `.isPresent()` for example.

Lots of things in the language that allow you to shoot yourself in the foot that other languages have solved.

Re:My most common code review suggestions by hyperpallium on Thursday December 07, 2017 @08:28AM (#15869776)
Semantically, is that different from using a reference variable without first checking it !=null?

Also, isn't there a static code analysis tool that checks at compile-time that reference variables annotated as @non_nullable can never be null?

Re:My most common code review suggestions by AstralStorm on Thursday December 07, 2017 @09:33AM (#15870226)
There is exactly one place where you might want to catch an NPE: top level global exception handler for logging and debugging.