D.Decorator

  1. Summary

      1. This pattern is designed to add new responsibility or state to the object at run time.

      2. It actually implements dynamic object extension instead of class extension (that is always compile time) conceptually it is achieved by using linked structure like linked list.

  2. Overview Tutorial

  1. Uses and Example

      1. Coffee Building example (Head First)

  1. Specific problems and Consideration

    1. Adapter Pattern Vs Decorator

        1. A decorator is different from an adapter in that a decorator changes object's responsibilities, while an adapter changes an object interface.

    2. Composite Pattern Vs Decorator

        1. A decorator can be viewed as a degenerate composite with only one component. However, a decorator adds additional responsibilities

  1. Pros and Cons

      1. Decoration is more convenient for adding functionalities to objects instead of entire classes at runtime. With decoration it is also possible to remove the added functionalities dynamically.

      2. Decoration adds functionality to objects at runtime which would make debugging system functionality harder.