Decorator: Add responsibilities to objects dynamically. Attach
additional responsibilities to an object dynamically. Decorators provide
a flexible alternative to subclassing for extending functionality.
Nearly same with composite. you can think it as "only one component
composite". But it is not aggregation of object, but add a layer of
decoration.
decorate avoid static implement all permutation. composite make all
component can be deal with in the same manner.
In Gof example, If we don’t use decorator. We need to inherit
from textview and produce scrolltextview and bordertextview. At this
time, if we need scroll and border together, we also need to define
scroolbordertextview class. It’s very bad design. 1) it will produce too
many classes and 2) you can’t change it dynamically.