Intent
- Provide a place holder object for null cases such that code doesn't have
to handle this special case
Applicability
- an object requires a collaborator but sometimes the collaborator should
do nothing
- clients should be able to ignore the differences between a real collaborator
and a collaborator that does nothing
Structure
[to do: diagram with: Client, Interface, RealObject and NullObject]
Consequences
- eliminats special cases for handling nil
- polymorphic not conditional code
- transparent support for optional collaborators
- null behaviour is reusable
Implementation
- creating null objects for each abstraction is tedious
- null objects are often stateless and shareable
Uses in JHotDraw