(no title)
wh0knows | 1 year ago
I can’t remember the last time I encountered one by using the proper compile time checks. It does need to be enforced organization-wide, and not partially with annotations, but if you can make that change then you can code in Java without the mental overhead of null.
chuckadams|1 year ago
wh0knows|1 year ago
lolinder|1 year ago
wh0knows|1 year ago
Or simply wrap the return with Optional.ofNullable, checkstyle will not accept it if you don’t.
The_Colonel|1 year ago
> then you can pretty much eliminate NPE.
NPEs is only one kind of cost incurred by the lack of null safety. The other is all the unnecessary "if (x == null) {" boilerplate code caused by the uncertainty and defensive programming, which increases complexity and worsens readability.
mrkeen|1 year ago
When you're sufficiently careful, you can reduce accidental nulls down to the level of minor inconvenience.
But no amount of care on your part will stop your teammates from deliberately using nulls.
ivan_gammel|1 year ago