Decorator< Computer Science Design Patterns
The decorator pattern helps to add behavior or responsibilities to an object. This is also called “Wrapper”.
This pattern can be very expensive. You should only use it when it is really necessary. You should have lots of different behaviors and responsibilities for the same class.
This pattern is expensive to create.
This pattern can be expensive to maintain. If the representation of a class often changes, you will have lots of refactoring.
This pattern is hard to remove too.
- Put the decorator term in the name of the decorator classes to indicate the use of the pattern to the other developers.
The decorator pattern can also be implemented in dynamic languages either with interfaces or with traditional OOP inheritance.