Decorator


Usage

  • Also known as: Wrapper
  • Add responsibilities to objects dynamically
  • Attach additional responsibilities to an object dynamically
  • Provide a flexible alternative to subclassing for extending functionality

Diagram

Decorator

Participants

Component
  • Defines the interface for objects that can have responsibilities added to them dynamically.
ConcreteComponent
  • Defines an object to which additional responsibilities can be attached.
Decorator
  • Maintains a reference to a Component object and defines an interface that conforms to Component's interface.
ConcreteDecorator
  • Adds responsibilities to the component.
Resources URL: 
notes/design_patterns/resources
Sources URL: 
notes/design_patterns/sources

See Also