# Null Object: A Safe Stand-In for Nothing

When a room has no speaker, every routine that plays something has to check for null first, and the one that forgets crashes the morning; a Null Object gives the room a speaker that safely does nothing, so the routines need no checks at all.

Journeyman · OOP · Updated November 17, 2026

By Gregor Dzierzon

## After this lesson you can

- Replace a missing object with a stand-in that safely does nothing, so callers need no null checks
- Spot the smells that point to Null Object: the same null check copied into every caller

## Key takeaways

- The smell: the same "is it null?" check copied into every piece of code that uses something that might be missing.
- The cause: "nothing" is stored as null, so every caller has to remember to ask before using it.
- The fix: a stand-in that keeps the same promise and does nothing, such as a NoSpeaker, so callers treat every room the same.
- The ?. shortcut makes each check shorter but leaves one in every caller; a null object removes them.
- Skip it when "nothing" is a problem someone should notice, such as a missing lock on the front door.

**Before this:** *Meet the Smart-Home Hub* (the hub's own `Speaker` promise), and interfaces (a promise any class can keep).

Maya's house has a new bedroom, and its speaker hasn't arrived yet. Every routine the hub runs goes from room to room: "good morning" plays the news on each room's speaker, and "good night" stops them all. A room with no speaker turns every one of those routines into a place the morning can crash. By the end of this lesson you'll have met a small pattern for exactly this, called *Null Object*.

## The symptom: the same check in every routine

In these examples a room's real speaker is a `RoomSpeaker`, the hub's own class for a room's speaker (behind it, the `TuneoSpeakerAdapter` from *Adapter*); here it prints what it plays. The hub stores "this room has no speaker" the usual way, as `null` (`None` in Python): a value that means "nothing here". Here are the two routines, each checking first:

```csharp
List<Room> house = new List<Room>
{
    new Room("Living room", new RoomSpeaker("Living room")),
    new Room("Kitchen", new RoomSpeaker("Kitchen")),
    new Room("Bedroom", null), // no speaker yet
};

GoodMorning(house);
GoodNight(house);

void GoodMorning(List<Room> rooms)
{
    Console.WriteLine("Good morning:");
    foreach (Room room in rooms)
    {
        if (room.Speaker != null)
        {
            room.Speaker.Play("https://tuneo.example/news");
        }
    }
}

void GoodNight(List<Room> rooms)
{
    Console.WriteLine("Good night:");
    foreach (Room room in rooms)
    {
        if (room.Speaker != null)
        {
            room.Speaker.Stop();
        }
    }
}

interface ISpeaker
{
    void Play(string station);
    void Stop();
}

class RoomSpeaker : ISpeaker
{
    private readonly string room;
    public RoomSpeaker(string room) { this.room = room; }
    public void Play(string station) => Console.WriteLine($"{room} speaker: playing {station}");
    public void Stop() => Console.WriteLine($"{room} speaker: stopped");
}

record Room(string Name, ISpeaker? Speaker);
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```java
interface Speaker {
    void play(String station);
    void stop();
}

class RoomSpeaker implements Speaker {
    private final String room;
    RoomSpeaker(String room) { this.room = room; }
    public void play(String station) { IO.println(room + " speaker: playing " + station); }
    public void stop() { IO.println(room + " speaker: stopped"); }
}

record Room(String name, Speaker speaker) {}

void goodMorning(List<Room> rooms) {
    IO.println("Good morning:");
    for (Room room : rooms) {
        if (room.speaker() != null) {
            room.speaker().play("https://tuneo.example/news");
        }
    }
}

void goodNight(List<Room> rooms) {
    IO.println("Good night:");
    for (Room room : rooms) {
        if (room.speaker() != null) {
            room.speaker().stop();
        }
    }
}

void main() {
    List<Room> house = List.of(
        new Room("Living room", new RoomSpeaker("Living room")),
        new Room("Kitchen", new RoomSpeaker("Kitchen")),
        new Room("Bedroom", null)); // no speaker yet
    goodMorning(house);
    goodNight(house);
}
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```python
class RoomSpeaker:
    def __init__(self, room):
        self.room = room

    def play(self, station):
        print(f"{self.room} speaker: playing {station}")

    def stop(self):
        print(f"{self.room} speaker: stopped")


class Room:
    def __init__(self, name, speaker):
        self.name = name
        self.speaker = speaker


def good_morning(rooms):
    print("Good morning:")
    for room in rooms:
        if room.speaker is not None:
            room.speaker.play("https://tuneo.example/news")


def good_night(rooms):
    print("Good night:")
    for room in rooms:
        if room.speaker is not None:
            room.speaker.stop()


house = [
    Room("Living room", RoomSpeaker("Living room")),
    Room("Kitchen", RoomSpeaker("Kitchen")),
    Room("Bedroom", None),  # no speaker yet
]
good_morning(house)
good_night(house)
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```javascript
class RoomSpeaker {
  #room;
  constructor(room) { this.#room = room; }
  play(station) { console.log(`${this.#room} speaker: playing ${station}`); }
  stop() { console.log(`${this.#room} speaker: stopped`); }
}

class Room {
  constructor(name, speaker) {
    this.name = name;
    this.speaker = speaker;
  }
}

function goodMorning(rooms) {
  console.log("Good morning:");
  for (const room of rooms) {
    if (room.speaker !== null) {
      room.speaker.play("https://tuneo.example/news");
    }
  }
}

function goodNight(rooms) {
  console.log("Good night:");
  for (const room of rooms) {
    if (room.speaker !== null) {
      room.speaker.stop();
    }
  }
}

const house = [
  new Room("Living room", new RoomSpeaker("Living room")),
  new Room("Kitchen", new RoomSpeaker("Kitchen")),
  new Room("Bedroom", null), // no speaker yet
];
goodMorning(house);
goodNight(house);
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```typescript
interface Speaker {
  play(station: string): void;
  stop(): void;
}

class RoomSpeaker implements Speaker {
  #room: string;
  constructor(room: string) { this.#room = room; }
  play(station: string): void { console.log(`${this.#room} speaker: playing ${station}`); }
  stop(): void { console.log(`${this.#room} speaker: stopped`); }
}

class Room {
  name: string;
  speaker: Speaker | null;
  constructor(name: string, speaker: Speaker | null) {
    this.name = name;
    this.speaker = speaker;
  }
}

function goodMorning(rooms: Room[]): void {
  console.log("Good morning:");
  for (const room of rooms) {
    if (room.speaker !== null) {
      room.speaker.play("https://tuneo.example/news");
    }
  }
}

function goodNight(rooms: Room[]): void {
  console.log("Good night:");
  for (const room of rooms) {
    if (room.speaker !== null) {
      room.speaker.stop();
    }
  }
}

const house = [
  new Room("Living room", new RoomSpeaker("Living room")),
  new Room("Kitchen", new RoomSpeaker("Kitchen")),
  new Room("Bedroom", null), // no speaker yet
];
goodMorning(house);
goodNight(house);
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

It works, as long as nobody forgets. Last week Leo, one of HomeBase's developers, wrote a third routine, "dinner time", which plays music in every room. He forgot the check, and the first evening it reached the bedroom, the routine stopped with an error and the kitchen never got its music. Movie night and the alarm's announcements will need the same check, and so will every routine anyone writes from now on.

- **The symptom:** the same `if (speaker != null)` copied into every piece of code that uses a speaker, and a crash wherever one copy is missing.
- **The cause:** "no speaker" is stored as `null`, which isn't a speaker at all. Every caller has to remember to ask before using it.

## What would you try?

**Keep the checks, and be careful.** That's what we have. It works until the one routine where somebody isn't careful, and a missing check only shows up on the day a room has no speaker.

**Catch the error instead.** Wrap each routine's call in `try`/`catch`. That's the same check in a bigger costume, still copied into every routine, and it can hide real errors from a speaker that *is* there.

**Never let a room exist without a speaker.** Refuse to add the bedroom until its speaker arrives. That blocks the lights and the lock in that room too, because one device is late.

What we want is a room that *always* has a speaker the routines can call, even when no speaker is installed.

## The fix: a speaker that does nothing

Websites do this when someone hasn't uploaded a profile picture. The page doesn't leave a hole or show an error; it shows a plain gray outline of a head. Every part of the site that shows pictures shows that one, and none of them has to ask "is there a picture?" first.

![A website's list of three members, where two show their own photos and the third, who hasn't uploaded one, shows a plain gray outline of a head in the same round frame, so the list looks complete](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/d921b5efb343404bafc2251f0211a7a2.webp)

The hub can do the same. Give the bedroom a **speaker that does nothing**: it keeps the same `Speaker` promise, so it has `play` and `stop`, and both are empty. The routines call it like any other speaker, and nothing happens. Nobody checks for null, because there's no null left to check for.

![Null Object's roles: the routine asks a speaker, the promise every room's speaker keeps. Two kinds keep it: a real speaker (RoomSpeaker), which plays, and the speaker that does nothing (NoSpeaker), both in a dashed fence labeled "what changes: is there a real speaker?"](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/97360e80e7cc4243921deb40feef3fb6.webp)

### The classic version: a NoSpeaker class

The bedroom gets a `NoSpeaker`, and a room built without a speaker gets one automatically:

```csharp
List<Room> house = new List<Room>
{
    new Room("Living room", new RoomSpeaker("Living room")),
    new Room("Kitchen", new RoomSpeaker("Kitchen")),
    new Room("Bedroom"), // no speaker yet: it gets a NoSpeaker
};

GoodMorning(house);
GoodNight(house);

void GoodMorning(List<Room> rooms)
{
    Console.WriteLine("Good morning:");
    foreach (Room room in rooms)
    {
        room.Speaker.Play("https://tuneo.example/news");
    }
}

void GoodNight(List<Room> rooms)
{
    Console.WriteLine("Good night:");
    foreach (Room room in rooms)
    {
        room.Speaker.Stop();
    }
}

interface ISpeaker
{
    void Play(string station);
    void Stop();
}

class RoomSpeaker : ISpeaker
{
    private readonly string room;
    public RoomSpeaker(string room) { this.room = room; }
    public void Play(string station) => Console.WriteLine($"{room} speaker: playing {station}");
    public void Stop() => Console.WriteLine($"{room} speaker: stopped");
}

class NoSpeaker : ISpeaker
{
    public void Play(string station) { } // no speaker here: nothing to play on
    public void Stop() { }
}

record Room(string Name, ISpeaker Speaker)
{
    public Room(string name) : this(name, new NoSpeaker()) { }
}
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```java
interface Speaker {
    void play(String station);
    void stop();
}

class RoomSpeaker implements Speaker {
    private final String room;
    RoomSpeaker(String room) { this.room = room; }
    public void play(String station) { IO.println(room + " speaker: playing " + station); }
    public void stop() { IO.println(room + " speaker: stopped"); }
}

record NoSpeaker() implements Speaker {
    public void play(String station) { } // no speaker here: nothing to play on
    public void stop() { }
}

record Room(String name, Speaker speaker) {
    Room(String name) { this(name, new NoSpeaker()); }
}

void goodMorning(List<Room> rooms) {
    IO.println("Good morning:");
    for (Room room : rooms) {
        room.speaker().play("https://tuneo.example/news");
    }
}

void goodNight(List<Room> rooms) {
    IO.println("Good night:");
    for (Room room : rooms) {
        room.speaker().stop();
    }
}

void main() {
    List<Room> house = List.of(
        new Room("Living room", new RoomSpeaker("Living room")),
        new Room("Kitchen", new RoomSpeaker("Kitchen")),
        new Room("Bedroom")); // no speaker yet: it gets a NoSpeaker
    goodMorning(house);
    goodNight(house);
}
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```python
class RoomSpeaker:
    def __init__(self, room):
        self.room = room

    def play(self, station):
        print(f"{self.room} speaker: playing {station}")

    def stop(self):
        print(f"{self.room} speaker: stopped")


class NoSpeaker:
    def play(self, station):
        pass  # no speaker here: nothing to play on

    def stop(self):
        pass


class Room:
    def __init__(self, name, speaker=None):
        self.name = name
        self.speaker = speaker if speaker is not None else NoSpeaker()


def good_morning(rooms):
    print("Good morning:")
    for room in rooms:
        room.speaker.play("https://tuneo.example/news")


def good_night(rooms):
    print("Good night:")
    for room in rooms:
        room.speaker.stop()


house = [
    Room("Living room", RoomSpeaker("Living room")),
    Room("Kitchen", RoomSpeaker("Kitchen")),
    Room("Bedroom"),  # no speaker yet: it gets a NoSpeaker
]
good_morning(house)
good_night(house)
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```javascript
class RoomSpeaker {
  #room;
  constructor(room) { this.#room = room; }
  play(station) { console.log(`${this.#room} speaker: playing ${station}`); }
  stop() { console.log(`${this.#room} speaker: stopped`); }
}

class NoSpeaker {
  play(station) {} // no speaker here: nothing to play on
  stop() {}
}

class Room {
  constructor(name, speaker = new NoSpeaker()) {
    this.name = name;
    this.speaker = speaker;
  }
}

function goodMorning(rooms) {
  console.log("Good morning:");
  for (const room of rooms) {
    room.speaker.play("https://tuneo.example/news");
  }
}

function goodNight(rooms) {
  console.log("Good night:");
  for (const room of rooms) {
    room.speaker.stop();
  }
}

const house = [
  new Room("Living room", new RoomSpeaker("Living room")),
  new Room("Kitchen", new RoomSpeaker("Kitchen")),
  new Room("Bedroom"), // no speaker yet: it gets a NoSpeaker
];
goodMorning(house);
goodNight(house);
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```typescript
interface Speaker {
  play(station: string): void;
  stop(): void;
}

class RoomSpeaker implements Speaker {
  #room: string;
  constructor(room: string) { this.#room = room; }
  play(station: string): void { console.log(`${this.#room} speaker: playing ${station}`); }
  stop(): void { console.log(`${this.#room} speaker: stopped`); }
}

class NoSpeaker implements Speaker {
  play(station: string): void {} // no speaker here: nothing to play on
  stop(): void {}
}

class Room {
  name: string;
  speaker: Speaker;
  constructor(name: string, speaker: Speaker = new NoSpeaker()) {
    this.name = name;
    this.speaker = speaker;
  }
}

function goodMorning(rooms: Room[]): void {
  console.log("Good morning:");
  for (const room of rooms) {
    room.speaker.play("https://tuneo.example/news");
  }
}

function goodNight(rooms: Room[]): void {
  console.log("Good night:");
  for (const room of rooms) {
    room.speaker.stop();
  }
}

const house = [
  new Room("Living room", new RoomSpeaker("Living room")),
  new Room("Kitchen", new RoomSpeaker("Kitchen")),
  new Room("Bedroom"), // no speaker yet: it gets a NoSpeaker
];
goodMorning(house);
goodNight(house);
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

The output didn't change; the routines did. Neither one checks anything now, and Leo's dinner-time routine would have worked without him knowing the bedroom was different. When the bedroom's speaker arrives, the room gets a `RoomSpeaker`, and no routine changes. In Python and JavaScript, `NoSpeaker` keeps the promise by having the same two methods (any object with `play` and `stop` will do); in C#, Java and TypeScript it says so with `implements` (in Java, as a `record` with no fields, the shortest class that keeps a promise).

### The modern shortcut, and what it doesn't fix

C#, JavaScript and TypeScript have a shortcut for "call it only if it's there": `?.`, the null-conditional operator (optional chaining in JavaScript). Java's closest is `Optional`, and Python has no shortcut, so its check stays written out:

```csharp
List<Room> house = new List<Room>
{
    new Room("Living room", new RoomSpeaker("Living room")),
    new Room("Kitchen", new RoomSpeaker("Kitchen")),
    new Room("Bedroom", null), // no speaker yet
};

Console.WriteLine("Good morning:");
foreach (Room room in house)
{
    room.Speaker?.Play("https://tuneo.example/news"); // calls Play only when there's a speaker
}

Console.WriteLine("Good night:");
foreach (Room room in house)
{
    room.Speaker?.Stop();
}

interface ISpeaker
{
    void Play(string station);
    void Stop();
}

class RoomSpeaker : ISpeaker
{
    private readonly string room;
    public RoomSpeaker(string room) { this.room = room; }
    public void Play(string station) => Console.WriteLine($"{room} speaker: playing {station}");
    public void Stop() => Console.WriteLine($"{room} speaker: stopped");
}

record Room(string Name, ISpeaker? Speaker);
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```java
interface Speaker {
    void play(String station);
    void stop();
}

class RoomSpeaker implements Speaker {
    private final String room;
    RoomSpeaker(String room) { this.room = room; }
    public void play(String station) { IO.println(room + " speaker: playing " + station); }
    public void stop() { IO.println(room + " speaker: stopped"); }
}

record Room(String name, Speaker speaker) {}

void main() {
    List<Room> house = List.of(
        new Room("Living room", new RoomSpeaker("Living room")),
        new Room("Kitchen", new RoomSpeaker("Kitchen")),
        new Room("Bedroom", null)); // no speaker yet

    IO.println("Good morning:");
    for (Room room : house) {
        Optional.ofNullable(room.speaker()).ifPresent(speaker -> speaker.play("https://tuneo.example/news"));
    }

    IO.println("Good night:");
    for (Room room : house) {
        Optional.ofNullable(room.speaker()).ifPresent(Speaker::stop);
    }
}
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```python
class RoomSpeaker:
    def __init__(self, room):
        self.room = room

    def play(self, station):
        print(f"{self.room} speaker: playing {station}")

    def stop(self):
        print(f"{self.room} speaker: stopped")


class Room:
    def __init__(self, name, speaker):
        self.name = name
        self.speaker = speaker


house = [
    Room("Living room", RoomSpeaker("Living room")),
    Room("Kitchen", RoomSpeaker("Kitchen")),
    Room("Bedroom", None),  # no speaker yet
]

print("Good morning:")
for room in house:
    if room.speaker:  # Python has no ?. shortcut
        room.speaker.play("https://tuneo.example/news")

print("Good night:")
for room in house:
    if room.speaker:
        room.speaker.stop()
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```javascript
class RoomSpeaker {
  #room;
  constructor(room) { this.#room = room; }
  play(station) { console.log(`${this.#room} speaker: playing ${station}`); }
  stop() { console.log(`${this.#room} speaker: stopped`); }
}

class Room {
  constructor(name, speaker) {
    this.name = name;
    this.speaker = speaker;
  }
}

const house = [
  new Room("Living room", new RoomSpeaker("Living room")),
  new Room("Kitchen", new RoomSpeaker("Kitchen")),
  new Room("Bedroom", null), // no speaker yet
];

console.log("Good morning:");
for (const room of house) {
  room.speaker?.play("https://tuneo.example/news"); // calls play only when there's a speaker
}

console.log("Good night:");
for (const room of house) {
  room.speaker?.stop();
}
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

```typescript
interface Speaker {
  play(station: string): void;
  stop(): void;
}

class RoomSpeaker implements Speaker {
  #room: string;
  constructor(room: string) { this.#room = room; }
  play(station: string): void { console.log(`${this.#room} speaker: playing ${station}`); }
  stop(): void { console.log(`${this.#room} speaker: stopped`); }
}

class Room {
  name: string;
  speaker: Speaker | null;
  constructor(name: string, speaker: Speaker | null) {
    this.name = name;
    this.speaker = speaker;
  }
}

const house = [
  new Room("Living room", new RoomSpeaker("Living room")),
  new Room("Kitchen", new RoomSpeaker("Kitchen")),
  new Room("Bedroom", null), // no speaker yet
];

console.log("Good morning:");
for (const room of house) {
  room.speaker?.play("https://tuneo.example/news"); // calls play only when there's a speaker
}

console.log("Good night:");
for (const room of house) {
  room.speaker?.stop();
}
```

```text
Good morning:
Living room speaker: playing https://tuneo.example/news
Kitchen speaker: playing https://tuneo.example/news
Good night:
Living room speaker: stopped
Kitchen speaker: stopped
```

Each check is shorter, and it's still there, once in every routine. Forget the `?` in dinner time and it crashes exactly as before. The shortcut is the right tool when *one* place has to cope with "maybe nothing"; when every caller would need it, the null object takes the question away from all of them at once.

## How it got its name

A **null object** is an object that stands in for "nothing": it keeps the same promise as the real thing, and its methods do nothing (or return something harmless, such as an empty list). Teams kept writing these do-nothing stand-ins to get rid of null checks, and the fix was written up as the **Null Object pattern** in the late 1990s, a few years after the original 1994 pattern book. This one has no modern replacement; it's already as small as a class gets.

## Where you've already used it

- **An empty list instead of null.** A method that returns `[]` when there's nothing to return, so callers can loop without checking, is the most common null object there is. Java's `List.of()` and C#'s `Enumerable.Empty<T>()` exist for exactly this.
- **Loggers that log nothing.** .NET's `NullLogger.Instance` and Python's `logging.NullHandler` let code call `log(...)` when nobody wants the log.
- **The do-nothing file.** `/dev/null` on macOS and Linux (`NUL` on Windows) is a file that accepts anything written to it and keeps none of it.

## When not to use it

- **When "nothing" is a problem someone should notice.** A missing speaker is harmless; a missing lock on the front door isn't. A `NoLock` whose `lock()` quietly does nothing would let "good night" report the house as locked when it isn't. When the missing thing matters, let the error show, or check on purpose and tell someone.
- **When callers really do need to act differently.** If the bedroom should send Maya a "your speaker hasn't been installed" note, that's a decision, and an `if` that makes it is honest code.
- **When the stand-in has to guess an answer.** A do-nothing `play` is easy. A do-nothing `volume()` has to return *some* number, and any number it picks may mislead the code that asked.

The cost is small: one more class, and a bug can hide a little longer, because a routine that sends commands to a `NoSpeaker` gives no sign that anything was skipped.

**How often you'll meet it:** now and then (our estimate: as empty lists and do-nothing loggers, more often than you'd think; as a hand-written class, now and then).

## Check yourself

2 questions to try on the lesson page.

## So what

When the same "is it null?" check turns up in every caller, give the missing thing a stand-in that keeps the promise and does nothing. The callers get simpler, the next routine can't forget the check, and the decision about what "nothing" means lives in one small class.

## Key terms

- [Null Object Pattern](https://www.ask-codey.com/glossary/null-object-pattern)
- [Code Smell](https://www.ask-codey.com/glossary/code-smell)
- [Null](https://www.ask-codey.com/glossary/null-software-development)

## Cheat sheets

- [Null Object: A Safe Stand-In for Nothing](https://www.ask-codey.com/cheat-sheets/dp-null-object-cheat-sheet)

Source: https://www.ask-codey.com/lessons/dp-null-object
