Hey folks!!! Happy to see you here.
We will be starting with our series on Design Patterns, where you will get to see the patterns in the most basic form with an extensive set of examples.
Let's start with setting up the context for today's article.
Design Patterns. What and Why?
Design Patterns are a blueprint or reusable template for commonly recurring challenges in Object oriented software design.
Design patterns are nowhere directly related to code, which also makes them independent of the programming language. They are high-level solutions carved out after identifying the patterns in the problems encountered frequently by developers. Once you understand the pattern, that is used to construct the solution for the use case underlying the pattern.
Also, adding a pattern as a solution reduces engineering and helps retain uniformity in systems, which is really important while you are building a system in teams. Along with that, it also helps maintainability and readability of the code because of the common vocabulary design patterns provides.
In other words, it can be referred to as a description of a solution, that can be used in different situations. Note that, design patterns should not be confused with the algorithms, as algorithms are sequences of actions to be executed that are pre-defined.
Now that, we know what design patterns are, and their importance, let's move to the different types of patterns. They can be mainly broken down into three parts, on the basis of their intent.
Creational, Structural, and Behavioral patterns are the three main types of patterns which we will also be discussed along with their various patterns under these buckets. Basically, these are the patterns meant to cover the lifecycle of process of building a system, which tells how to create objects, structure classed to form a sub-system, and how to make your objects interact with each other.
Let’s get an overview of the above three main types of patterns.
Creational Patterns:
These are basically related to the way classes are instantiated and objects are created. These are used when we have specific use-cases where some action is needed right when the object is created or at the time of instantiation of the class. These are aimed to provide a more general and flexible approach of creating an object.
Example of a creational pattern
Structural Design Patterns:
These patterns are concerned with assembling the objects and classes together to form a larger subsystem that is extensible and offers additional functionality.
Example of a structural design pattern
Behavioral Design Patterns:
These patterns are concerned with algorithms and the assignment of responsibilities of new objects, and also focus on how objects communicate with each other while still being loosely coupled.
Example of a behavioral design pattern
We have learned about the overview of design patterns, their importance, and the three main types in brief. In upcoming articles, I will be bringing you extensive coverage of each pattern under all types, with code examples for free.
That’s it and if you found this article helpful, please click the clap 👏button below, you can also follow me on Twitter, subscribe to my weekly newsletter here, and if you have any doubt, feel free to comment! I’d be happy to help. 🤘🏻
Top comments (0)