© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
D. NesterukDesign Patterns in .NET 6https://doi.org/10.1007/978-1-4842-8245-8_21

21. Null Object

Dmitri Nesteruk1  
(1)
St. Petersburg, c.St-Petersburg, Russia
 

We don’t always choose the interfaces we work with. For example, I’d rather have my car drive me to my destination by itself, without me having to give 100% of my attention to the road and the dangerous lunatics driving next to me. And it’s the same with software: sometimes you don’t really want a piece of functionality, but it’s built into the interface. This means you have to provide some value even if you don’t need this particular piece of functionality.

So what do you do? You make a null object. ...

Get Design Patterns in .NET 6: Reusable Approaches in C# and F# for Object-Oriented Software Design 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.