Sunday, May 7, 2017

Avoiding null's -> becoming better programmer ;-)

From some time all my IntelliJ's are showing usage of null as error.
I created inspection (if you want you may download it and add to your IntelliJ) which cause that my code which is using null looks like this:

This caused that I started to use Optional more often, and even started to read InputStreams different than earlier ;-)

Mainly because of this that when I'm on autopilot and put null into code, this is marked as error and I must start to think about better solution.

Of course, sometimes null is needed and helpful, but it is also very error prone.
Each usage of null means being closer to moment when you will return null, and this will lead to NullPointerException in less expected moment.

Similar postsbeta
Blindfold programming
OpenOffice.org2GoogleDocs 1.0.4
Coding time means often waiting/reading time ;-)
OOo2GD 2.1.1 is ready :-)
My Clipboard says that I'm a programmer ;-)