Extract Decorator
Decorators can be used to lay new concerns on top of existing objects with- out modifying existing classes. They combine best with small classes with few methods, and make the most sense when modifying the behavior of existing methods, rather than adding new methods.
- Extract a new decorator class, starting with the alternative behavior.
- Compose the decorator in the original class.
- Move state specific to the alternate behavior into the decorator.
- Invert control, applying the decorator to the original class from its con- tainer, rather than composing the decorator from the original class.
It will be difficult to make use of decorators unless your application is following Composition Over Inheritance⭐.