According to the Design Pattern book titled “Design Patterns: Elements of Reusable Object-Oriented Software”, there are altogether twenty-three design patterns. This book was written and published by four authors namely John Vlissides, Erich Gamma, Ralph Johnson, and Richard Helm. These four authors who hold the fundamental responsibility of introducing Design Patterns in the field of software programming are termed as “Gang of Four” authors, in short as GOF.
As per these authors, the GOF Design Patterns are classified into three different categories namely:
- Creational Design Patterns
- Structural Design Patterns
- Behavioral Design Patterns
Through this article, we will learn about the above mentioned categories in detail.
Creational Design Patterns:
Creational Design Pattern provides a methodology for creating objects by hiding the logic of object creation. Creational Design Pattern talks about “when should the objects be created?” and “How should the objects be created?”.
Types of Creational Design Patterns:
Among the 23 GOF Design Patterns, 5 design patterns fall under the category of “Creational Design Patterns”. They are:
- Factory Pattern: To create an object of numerous derived classes.
- Abstract Factory Pattern: To create an object of numerous families of classes.
- Builder Pattern: To separate object construction and object representation.
- Prototype Pattern: To copy or clone a fully initialized object.
- Singleton Pattern: To create only one object / instance for a particular class.
Structural Design Patterns:
Structural Design Pattern is concerned about composition of class and composition of object.
Types of Structural Design Patterns:
Among the 23 GOF Design Patterns, 7 design patterns fall under the category of “Structural Design Patterns”. They are:
- Adapter Pattern –To match the interfaces of diverse classes.
- Bridge Pattern – To separate interface of an object from the implementation of that object.
- Composite Pattern – To create a tree structure encompassing simple objects and composite objects.
- Decorator Pattern – To dynamically add objects with their responsibilities.
- Façade Pattern – To use a single class to represent a whole subsystem.
- Flyweight Pattern –To efficiently share instance that is fine-grained.
- Proxy Pattern – To demonstrate an object that represents another object.
Behavioral Design Patterns:
Behavioral Design Patterns are concerned about object communication.
Types of Behavioral Design Patterns:
Among the 23 GOF Design Patterns, 11 design patterns fall under the category of “Structural Design Patterns”. They are:
- Chain of Responsibility Pattern – To pass a request through a chain of objects.
- Command Pattern – To encapsulate command request by way of an object.
- Interpreter Pattern – To incorporate language elements within a program.
- Iterator Pattern – To sequentially access collection elements.
- Mediator Pattern – To define simplified communication among classes.
- Memento Pattern – To capture and to restore the internal state of an object.
- Observer Pattern – To notify change to several classes.
- State Pattern – To alter the behavior of an object when there is an associated state change.
- Strategy Pattern – To encapsulate an algorithm within a class.
- Template Method Pattern – To defer the actual algorithmic steps to a subclass.
- Visitor Pattern – To define a new operation for a class without changing it.
Leave a Reply