3 ms·
Ask HN: 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 5y agoWhat 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?
- breckenedge 5y agoThanks for the response. It’s a Ruby app. It’s a Hash object where one of the keys might contain nil but more methods are called on it.