Brief description :
A code block that uses null pointers as flags for exceptional conditions is signalling a NullPointerException.
How to avoid them :
Throw exceptions to signal exceptional conditions.
Or NullObject pattern.
Guidance:
- If the null indicates an error condition, something that should not be processed, throw an exception.
- If the null should be "processed" by later code -- specifically including that code doing nothing when it sees the null -- use the NullObject pattern.
- If you see several (or many) places in the code where it checks to see if some particular value is null, and does special processing in that case, use the NullObject pattern: Make the NullObject implementation responsible for consistently performing the special processing.
Excerpt from
http://www.ibm.com/developerworks/java/library/j-diag3.html
AntiPatternsCatalog