APPLIED DESIGN PATTERNS

Why You Need Null Objects

Let me tell you why this weird pseudo null-object is so great

Level Up Coding
Published in
4 min readJun 11, 2020

--

So, I wrote this piece “Stop Checking for Nulls” and it took some heat from a few developers doubting the NOP’s usefulness. I figured I’d take some time and provide additional examples.

For those who didn’t read the previous article and still don’t know what a Null Object is, here’s a simple explanation.

The main purpose is to return a suitable substitute for a null. The Null Object simply allows for more expressive code.

Let’s have a look at some examples when the Null Object is more expressive than just using nulls that’d easily wreck your application.

1 Lying method signatures

A method signature may lie about what it does in two ways: 1) the return type, and 2) the method name is incorrect.

--

--

I mostly write to "future me" sharing what I learn and my opinion on software development practices. youtube.com/@nmillard | open for contracts in Jan 2026.