Purpose:
Attach additional responsiblities to an object dynamically, which thus
provide a flexible alternative to subclassing for extending
functionality.
Structure:
Typically, there will be a parameter to pass original object to
decorator object in its constructor, then decorator can implement
additional functions within its own interface and apply to original
object.
when to use:
-- when subclassing is not avaible
-- when the responsibilities (for different functions) are required flexiable and dynamical
-- can not predict combination of extending functionality. (We can not
design subclasses for all combination of potential additional
functionalities at compile time)
reference:
Book: Design Pattern (GoF)
http://en.wikipedia.org/wiki/Decorator_pattern