First page Back Continue Last page Overview Graphics
Decorator Design Pattern (cont.)
Motivation
- It is easy to add functionality to an entire class of objects by subclassing an object, but it is impossible to extend a single object this way. With the Decorator Pattern, you can add functionality to a single object and leave others like it unmodified.
- The component which we want to extend is wrapped (or enclosed) within another object that adds the required functionality. This enclosing object is called a decorator.
- The decorator conforms to the interface of the component it encloses, so that its presence is transparent to the component's clients.