Thursday, November 3, 2011

Design Pattern : behavioural

  1. Chain of responsibility
    1. The purpose for this is for high cohesion. This means, to increase the reusability.
    2. This can be visualized with the specialization in manufacturing world. Each function performs specialized task, and chained together to perform a bigger task.
    3. These functions can be reused in other scope since they are doing specialized and simpler task.
  2. Command
    1. This is to encapsulate requests.
    2. Thus, for a program to call any command, it has the similar interface.
  3. Interpreter
    1. This will translate the context passed by client and perform necessary task on it.
  4. Iterator
    1. This to enable to parse through the whole data structure.
  5. Mediator
    1. As a middle man between 2 sub-program to enable low coupling, or for decoupling purpose.
  6. Momento
    1. This is to capture the state of the class and stored in another object
    2. Good for undo to restore the object to its previous state
  7. Observer
    1. It’s for event driven.
    2. As listener, or “don’t call me, I’ll call you”
    3.  (After reading the online notes, I am not convinced by what was told in the class, so, please see d)
    4. objects need to be registered, the changes will be applied to all objects
  8. State
    1. This is to allow control on the behavior of the object when its internal state changes.
  9. Strategy
    1. Similar to state, but in different context.
    2. Different algorithms are implemented in child classes.
  10. Template method
    1. Preparing the abstraction/skeleton of the classes in the base class.
  11. Visitor
    1. To improve for high cohesion
    2. Slightly similar to Mediator, but mediator create the element class, while visitor does not. The element is created by client, and visitor is accepted by client to perform operation on element.
  12. Null object method
    1. This is used to handle “null object”. This null object is a real object, while it will not be set or do nothing when it is called.

No comments:

Post a Comment