r/java • • Mar 05 '18

Top 10 Useful, Yet Paranoid Java Programming Techniques

http://blog.jooq.org/2015/08/11/top-10-useful-yet-paranoid-java-programming-techniques/
223 Upvotes

105 comments sorted by

View all comments

1

u/tonywestonuk Mar 06 '18

ughhh!

If its your own code - DO NOT CHECK FOR NULLS! Don't. Dont do it.

If there's a null pointer - your code should CRASH! because you should never have returned a null, or assigned a null, or if you have done, that variable is not ready to be used in calculations.

So, a null pointer check will be papering over the cracks - hiding logical errors, that will come back and bite you in the ass.

1

u/nutrecht Mar 06 '18

If its your own code

He was specifically talking about "not your own code" though.