using an object before checking if it is null makes baby jesus cry.
c’mon people check your return value
better yet:
- Before you start writing a method, decide whether it will ever return null. Document this decision in the @return section of the method’s Javadoc.
- Never have a method return null unless there’s a really good reason for it.
- If your method returns an array or a collection, there’s no reason to ever return null. Return an empty array or collection instead.
- If you have a situation where null is a valid value for a variable, you can make use of the Introduce Null Object refactoring, to make the behaviour explicit.
Read more here.
zuh?
where could one find more information on what “Introduce Null Object refactoring” is?