Learn Design Patterns: Part 1
Tags: designpattens, cleancode, oop, pattern
Published: 2022-08-15 13:11:46

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.

![Designer](https://media.giphy.com/media/d31vTpVi1LAcDvdm/giphy.gif)

**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.

![Design Patterns](https://miro.medium.com/max/1400/1*EHEZA9d_ArShK5fUX7ZHmg.png)
**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.

![Creational Pattern](https://miro.medium.com/max/1400/1*0lVbRefb7dWGu8Vfb9Sb3Q.png)
_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.
![Structural Pattern](https://miro.medium.com/max/1400/1*rh1qW5q2FtukT4aYIKb38g.png)

_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.
![Behavioral Pattern](https://miro.medium.com/max/1400/1*2uNlAr6FvzWlskygQb0BuQ.png)
_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](https://twitter.com/Muddhit), subscribe to my weekly newsletter [here](https://muddhit.substack.com/?r=1npetb&s=w&utm_campaign=pub&utm_medium=web), and if you have any doubt, feel free to comment! I’d be happy to help. 🤘🏻