You may be wondering what gamma categorization is, so let me clarify that it is nothing more than the logical border formed around the various design patterns, or we can say that we basically divide the numerous design patterns into multiple categories, and that categorization is known as “Gamma Categorization.”
This category is named after the famous author “Erich Gamma, who was one of the authors of “Gang of Four."
So as per the book, various design patterns are generally categorized into 3 major types of categories, which are “Creational”, “Structural” and “Behavioral”, By looking at their names, one can easily tell their purpose without even having coding knowledge, and this simplicity made this categorization simple and more understandable. Due to its simple nature, this categorization gained popularity among the developers because people were able to understand the gist behind the workings of a pattern just by looking at its category name.
Let’s discuss these categories in detail so that we can also get to know about them and classify various patterns that we are going to discuss in coming blogs. This will help us to better understand the behavior of patterns and we can better utilize them in our code to make it more self-explanatory.
1. Creational
So as we know, the first category is "Creational,” and the design patterns that fall under this category are generally known as “Creational Design Patterns." The main goal of this design pattern is to focus on object creation. In modern languages like Java or C#, we have multiple ways to create or construct objects. Sometimes object creation is very simple, but sometimes it requires some efforts and simplifications; otherwise, there are high chances that a user might make an error unknowingly. We can create objects either explicitly, i.e., by using a typical constructor, or implicitly, i.e., using a dependency injection container, reflections, and many more, which create objects behind the scenes for us. And these patterns also determine if an object is created in one go (a whole object at a time) or if it is created by providing chunks or pieces (step-by-step creation).
2. Structural
Now after creational, we are going to see our second category, i.e., “Structural” and again the patterns that reside under this category are known as “Structural Design Patterns” and as the name suggests, we can easily predict that these patterns are used to shape our code or to form a fixed structure. This categorization is mainly focused on various concerns, which are very helpful in shaping the structure of the class. Structural design patterns are generally known for the structures formed by the patterns that mimic the underlying contracts, i.e., we can say that this pattern revolves around wrappers and concepts that help us shape the classes by providing some sort of structure that can mimic the underlying interface. By using structural patterns, one can achieve very good API design.
3. Behavioral
The third major category is “behavioral.”, Unlike the first two patterns, this does not follow any theme, and all patterns are different in their own way. We can say that they are unique by their individual implementations and can be used to solve particular problems with their unique approach.
At the end, I wanted to conclude that all these categories are useful in their own way, but it’s up to us how we can use them to make our code more understandable, and we should choose them wisely. One should first understand the requirements of the application, and then choose a pattern that is beneficial and can make his life easy. If we do so, then we can write better code that is self-explanatory, and new developers can also contribute faster to that code due to its minimal complexity.
Happy Coding…!!!
Top comments (0)