HACKER Q&A
📣 breckenedge

Null Object Pattern


Do people still recommend this pattern? I’m using a dynamic language without type checking, and null can certainly cause problems, but I’ve always found the overhead of maintaining a Null Object not worth the effort.


  👤 HelloNurse Accepted Answer ✓
What is the overhead of maintaining a null object? In most cases it can be a more or less global reference to an object without significant data and the cost is simply writing a "null" implementation of appropriate interfaces (which could already exist for free, for example empty strings).

What programming language and what kind of objects are you having trouble with?