If you’re checking for null before using an object or an attribute in an object, you need to think about whether your code is rotten.

What does null mean, and can you clarify its intent? Method returns null, is there an error or entry error or not found? Null is used as an argument to a method. What does null represent, whether no value is given or not. Also, if you return null or pass NULL, you add a null check to the subsequent steps.

Null can only be used syntactically, preferably not in business code, because you can’t tell what it’s meant to be. If a method returns NULL, the method is bad code. You call another method and you pass null, your code is bad code.

Using null does two things: 1. Do not return NULL; 2. Do not pass NULL.

Instead of returning NULL, throw an exception and return special case data (empty collection, empty array, empty string, etc.). You can also use Guava’s Optional instead.

By not passing NULL, reducing this step reduces the burden of subsequent validation.