Null Object
The intent of a Null Object is to encapsulate the absence of an object by providing a substitutable alternative that offers suitable default do nothing behavior. In short, a design where "nothing will come of nothing"
Example - Empty iterator instead of null
We are going to use null object to represent empty iterator. Then we use this iterator whenever we would want to return null.
Instead of returning or working with null, we return instance of NullIterator
.
Last updated
Was this helpful?