Decorator Design Pattern

Structural Design Pattern Summary Decorator design pattern is used to extend or decorate certain objects of a Class (not all objects) statically or at run time. Multiple decorators can act on an object to add the desired behavior to a particular object instance without effecting other instances. Decorator design pattern is a Structural design pattern, it is alternative to inheritance/ Sub classing in java. Java sub classing effects all the instances of the class, and some times it is not desirable. Difference between Decorator and Visitor Decorator design pattern works on a single object. Decorator design pattern helps in enhancing a single object with new functionality or behaviour. Decorator is a Structural design pattern, Visitor is a behavioral design pattern. Visitor works on composite objects. Visitor pattern is used to add a new algorithm or functionality to collection of objects or hierarchy of objects. Details Following are the Participants in this pat...