DEV Community

Discussion on: Understanding Design Patterns: Null Object

Collapse
 
drmaquino profile image
Mariano Aquino

The whole idea of the pattern is to let the client not know whether it is dealing with actual objects or nulls. It is usually used with "for-each"s and it is yet another case of polymorphism.
Your idea sounds good if you wanted to let the client decide what to do on each type, which is not the use case of this pattern.
Of course, different scenarios require different approaches.