Null Object pattern

With zero object is both a design pattern (English null object pattern ) the category of behavior patterns ( engl. behavioral pattern ) and named the object used in this design pattern (English null object). The design pattern null object is applied to the deactivation of references to variables and is to assign the reference an object that performs no action, rather than to invalidate the reference. This ensures that the reference refers to the variable at each time point to a valid object that is unnecessary treatments of special cases ( absence ).


  • It will minimize code duplication.
  • It prevents " null pointer exceptions" occur when an exception handling has been forgotten in a certain usage of the object.


  • A null object to replace the value " zero " must implement the public methods of the corresponding interface. The refactoring towards ' null object ' may therefore be consuming.


  • The null object can be implemented as a singleton (single piece ). This version uses less memory because only one instance of the zero object is instantiated.