Strategy Pattern

1. Usage Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from the clients that use it. Capture the abstraction in an interface, bury implementation details in derived classes. 2. UML class diagram 3. Pros greater flexibility, reuse can change algorithms dynamically 4. Cons strategy creation […]

Command pattern

1. Usage Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. The purpose of the Command pattern is to decouple an event generator (the Invoker) from the event handler (the Receiver). A ConcreteCommand class (sub-classed from Command) defines an execute ()method which […]

Iterator pattern

1. Usage Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. makes possible to decouple collection classes and algorithms. Promote to “full object status” the traversal of a collection. Polymorphic traversal 2. UML class diagram 3. Pros shields the client from the internal representation of aggregator. aggregate […]