O'Reilly logo

Quality Code: Software Testing Principles, Practices, and Patterns by Stephen Vance

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Use Existing No-Op Classes

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 undef, nil, or 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required