obligations to implement the subject or observer interfaces.
III. DECORATOR PATTERN
A. Definition
The Decorator Pattern attaches additional
responsibilities to an object dynamically. Decorators
provide a flexible alternative to sub-classing for extending
functionality. Decorators have the same super type as the
objects they decorate.
B. Description
We can use one or more decorators to wrap an object.
Given that the decorator has the same super type as the
object it decorates, we can pass around a decorated object in
place of the original object.
The decorator adds its own behavior either before and/or
after delegating to the object it decorates to do the rest of the
job.
Objects can be decorated at any time, so we can decorate
objects dynamically at runtime with as many decorators as
we like.
Figure