Introduction to design patterns
Design pattern are categorize in three parts
- Creational Patterns
- Structural Patterns
- Behavioral Patterns
1- Creational Patterns
The Creational design pattern is used to deal with the creation of objects. It is used, how the object is created and utilize in the application. It may be the simple object creation may increase the complexity that can be solved by creational design pattern. Creational design patterns are categories in five types.
- Abstract Factory A single Factory class that returns the different sub-classes based on the input provided and factory class uses if-else or switch statement to achieve this.
- Builder It providing a way to build the object step-by-step and provide a method that will actually return the final Object.
- Factory Method Creates an instance of several derived classes
- Prototype This pattern uses cloning to copy the object.
- Singleton It maintains the single instance of class
2- Structural Patterns
Structural design patterns are used to design the relationship between entities. It helps to structure our objects, the relationships and inheritance between classes & add additional functionality to an object at run time.
- Adapter The object that joins these unrelated interface is called an Adapter
- Bridge Separates an object’s interface from its implementation
- Composite When we need to create a structure in a way that the objects in the structure has to be treated the same way, we can apply composite design pattern.
- Decorator Add responsibilities to objects dynamically
- Facade A single class that represents an entire subsystem
- Flyweight A fine-grained instance used for efficient sharing
- Proxy An object representing another object
3- Behavioral Patterns
Behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns.
- Chain of Responsibility Multiple objects can handle a request and the handler doesn't have to be a specific object. A set of objects should be able to handle a request with the handler determined at run-time.
- Command Command pattern forwards the request to a specific module
- Interpreter A way to include language elements in a program
- Iterator Sequentially access the elements of a collection
- Mediator Defines simplified communication between classes
- Memento Capture and restore an object's internal state
- Observer A way of notifying change to a number of classes
- State Alter an object's behavior when its state changes
- Strategy Encapsulates an algorithm inside a class
- Template Method Defer the exact steps of an algorithm to a subclass
- Visitor Visitor lets you define a new operation without changing the classes of the elements on which it operates.
This comment has been removed by a blog administrator.
ReplyDelete