Template Method

1. Usage Define the skeleton of an algorithm in base class “Template Method” Steps required concrete implementation define as placeholders in base class Derifed classes fill-up placeholders with concrete implementations 2. UML class diagram 3. Pros shields the client from the details of the variant behaviour quality & productivity – only the variant behaviour needs […]

State Pattern

1. Usage Allow an object to change behavior when State changed. implements OOP Final State Machine(FSM) 2. UML class diagram Context is wrapper class – interface to state Define abstract state base class Define state specific behavior in derived state classes maintain pointer to current state in wrapper context class 3. Pros Easier to extend […]

Observer pattern

1. Usage Pattern Observer – define relationship “one to many” such way that when state of object change all dependent objects notified/updated automatically. Pattern Observer encapsulate main component in Subject abstraction and dependent objects in Observer hierarchy. Observer used IN MVC as View part This pattern used widely in User interfaces. 2. UML class diagram […]

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 […]

Builder

1. Usage To implement reusable mechanize of polymorphic pipeline to generate step by step final complex product. For example function “save as” document – as HTML, RTF, PDF. each plugin for different format will have its own way to serialize – table, image or title objects. 2. UML class diagram Source: https://sourcemaking.com/design_patterns/builder 3. Pros 4. […]