Decorator – Attach additional reponsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
- Classes should be open for extension but close for modification.
- Inheritance is one form of extension, but not necessarily the best way to achieve flexibility in our designs.
- In our designs we should allow behavior to be extended without the need to modify existing code.
- Compostion and delegation can often be used to add new behaviors at runtime.