© Vaskaran Sarcar 2020
V. SarcarDesign Patterns in C#https://doi.org/10.1007/978-1-4842-6062-3_25

25. Null Object Pattern

Vaskaran Sarcar1 
(1)
Garia, Kolkata, West Bengal, India
 

This chapter covers the Null Object pattern.

Definition

The Null Object pattern is not a GoF design pattern. I am taking the definition from Wikipedia, which says the following.

In object-oriented computer programming, a null object is an object with no referenced value or with defined neutral (‘null’) behavior. The null object design pattern describes the uses of such objects and their behavior (or lack thereof). It was first published in the Pattern Languages of Program Design book series.

Concept

The pattern can implement a “do-nothing” relationship, or it can provide a default ...

Get Design Patterns in C#: A Hands-on Guide with Real-world Examples now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.