The Decorator Pattern attaches additional responsibilites to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
-
Identify the aspects of your application that vary and separate them from what stays the same
-
Program to an interface, not an implementation.
-
Favor composition over inheritance.
-
Strive for loosely coupled designs between objects that interact.
-
Classes should be open for extension, but closed for modification.