- Chain of responsibility
- The purpose for this is for high cohesion. This means, to increase the reusability.
- This can be visualized with the specialization in manufacturing world. Each function performs specialized task, and chained together to perform a bigger task.
- These functions can be reused in other scope since they are doing specialized and simpler task.
- Command
- This is to encapsulate requests.
- Thus, for a program to call any command, it has the similar interface.
- Interpreter
- This will translate the context passed by client and perform necessary task on it.
- Iterator
- This to enable to parse through the whole data structure.
- Mediator
- As a middle man between 2 sub-program to enable low coupling, or for decoupling purpose.
- Momento
- This is to capture the state of the class and stored in another object
- Good for undo to restore the object to its previous state
- Observer
- It’s for event driven.
- As listener, or “don’t call me, I’ll call you”
- (After reading the online notes, I am not convinced by what was told in the class, so, please see d)
- objects need to be registered, the changes will be applied to all objects
- State
- This is to allow control on the behavior of the object when its internal state changes.
- Strategy
- Similar to state, but in different context.
- Different algorithms are implemented in child classes.
- Template method
- Preparing the abstraction/skeleton of the classes in the base class.
- Visitor
- To improve for high cohesion
- 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.
- Null object method
- 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.
Thursday, November 3, 2011
Design Pattern : behavioural
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment