Before we get started to the design patterns themselves, we need to have a general overview of the whole picture by looking at the so-called Gamma Categorization. So, what is that Gamma Categorization which is mentioned right now? Let's dive in!
1. What is Gamma Categorization?
Typically, the design patterns are split into three categories by Erich Gamma, one of GoF authors. The Gamma Categorization is named after him in his book: Design Patterns: Elements of Reusable Object-Oriented Software (1994).
The three categories are:
- Creational Patterns
- Structural Patterns
- Behavioral Patterns
2. Creational Patterns
In software engineering, the design patterns which deal with creating objects are in the Creational Design Patterns category. In a real project, the design problems or complexities in later phases of a program may be caused by the basic form of object creation. With a solid design involving Creational Design Patterns, the mentioned problems or complexities can be resolved.
The Creational Patterns:
- Deal with the creation (construction) of objects
- Explicit (constructor) vs. implicit (Dependency Injection, Reflection, etc.)
- Wholesale (single statement) vs. piecewise (step by step)
The Creational Design Patterns include:
- The Builder Design Pattern
- The Factory Design Pattern
- The Prototype Design Pattern
- The Singleton Design Pattern
3. Structural Patterns
As the name suggests, this category mainly concerns with the structure of the classes and relationships between entities. The structural design patterns simplifies the structure by identifying the relationships. These patterns focus on, how the classes inherit from each other and how they are composed from other classes.
The Structural Patterns:
- Concern with the structure (e.g., members of a class)
- Mimic the underlying class' interface
- Stress the importance of good API design
The Structural Design Patterns include:
- The Adapter Design Pattern
- The Bridge Design Pattern
- The Composite Design Pattern
- The Decorator Design Pattern
- The Facade Design Pattern
- The Flyweight Design Pattern
- The Proxy Design Pattern
4. Behavioral Pattern
When talking about Behavioral Pattern, it identifies the common communication patterns between objects and memorize them. By focusing on Behavioral Pattern, the communication patterns can be done more flexible between objects in the program.
The Behavioral Patterns:
- Concern with the assignment of responsibilities between objects, or, encapsulating behavior in an object and delegating requests to it
- Concentrate on the way objects are interconnected
The Behavioral Design Patterns include:
- The Chain of Responsibility Design Pattern
- The Command Design Pattern
- The Iterator Design Pattern
- The Mediator Design Pattern
- The Memento Design Pattern
- The Observer Design Pattern
- The State Design Pattern
- The Template Method Design Pattern
- The Strategy Design Pattern
- The Visitor Design Pattern
To sum up, if Creational is about instantiation, and Structural is the blueprint, then Behavioral is the pattern of the relationship among objects.