Skip to content

Technology Quote by Eric Freeman

“The NoCommand object is an example of a null object. A null object is useful when you don’t have a meaningful object to return, and yet you want to remove the responsibility for handling null from the client.” quote by Eric Freeman
Download Open image
““The NoCommand object is an example of a null object. A null object is useful when you don’t have a meaningful object to return, and yet you want to remove the responsibility for handling null from the client.””

Eric Freeman

About This Quote

Source Book: Head First Design Patterns by Eric Freeman, 2004

A null object provides a harmless default so client code need not check for null before using an object.

In simple terms: Use a default object to avoid null checks.

Key Takeaway

Implement null objects to simplify code.

Themes

software design error handling clean code

Mood

practical technical

Type

instructional technical

When to use this quote

  • API design
  • client code
  • error prevention

Key Concepts

null object pattern design patterns

Questions to Reflect On

  • When could a null object cause hidden bugs?
  • Is a null object always better than a null check?
A Different Perspective

Null objects can hide underlying design flaws.

2.4 out of 5 (6 ratings)

More by Eric Freeman

Explore all 90 Eric Freeman quotes

More Technology quotes

Browse all 12,247 Technology quotes