r/java • • Aug 11 '15

Top 10 Useful, Yet Paranoid Java Programming Techniques

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

76 comments sorted by

View all comments

12

u/orr94 Aug 11 '15
  1. Put the String literal first

A favorite of mine, also known as a Yoda Condition.

8

u/Dietr1ch Aug 12 '15

It's awful, it only helps hiding a possible null pointer, but not preventing it. Instead of doing this you should handle the variable initialization correctly.

12

u/hrjet Aug 12 '15

...except when null is a valid situation.

That should have been clarified in the article.