Design Patterns Basics
Design Patterns Basics
Agenda
Why Design Patterns ? Types of Design Patterns Rationale behind different Design Patterns
Abstract Factory Builder Factory Method Prototype Singleton Bridge Adaptor Composite Decorator Faade Flyweight Proxy Chain of Responsibility Command Interpreter Iterator Mediator Memento Observer State Strategy Template Method Visitor
Creational Patterns
Structural Patterns
Behavioral Patterns
Creational Patterns
Describes how classes and objects should be created idea is to make the system independent of how its objects are created and composed. Inheritance is used for varying the class that instantiated While, delegation is used for object instantiation
Structural Patterns
Describes how classes and objects should be composed to form larger structures Making 2 independently developed stuff work together e.g. Adapter Structure for sharing objects e.g. flyweight Building up class hierarchies e.g. Composite Dynamic and recursive composition of objects e.g. Decorator
Behavioral Patterns
Describing algorithms e.g. Strategy, template method Distributing responsibilities among objects e.g. chain of responsibility, mediator Describing the pattern of communication between objects e.g. observer, visitor etc.
Chain of Responsibility
Visitor
Rationale
If you have an Hierarchical data structure and you want to perform operations like saveInXML, saveIn YAML etc. on the complete structure, then following will be the sub-tasks
Traversal The Operation itself