In my opinion, one of the most underutilized of the common design patterns is the Null Object pattern.3 The concept is simple. Instead of returning the ubiquitous
null (or its various equivalents such as
NULL) and testing for it as a special value, we return an object of the expected type that implements the behavior associated with an unknown, missing, or indistinct value. Several such objects may reasonably exist for a given situation, giving rise to Martin Fowler’s Special Case pattern4 as a generalization.
3. Surprisingly to many, this is not one of the original Gang of Four design patterns but was first proposed in the Pattern Languages of Program Design series. Martin Fowler [REF], Josh Kerievsky ...