Software Design Patterns — Zero to Hero
I have been coding from 2017, related to web-development and automating boring stuff with Python. While coming across some cool stuff in Software Engineering I got to know about “Design Patterns”.
I saved that in my learning list last year. But I was not able to catch those patterns principle and how they are working, finally, in the academics syllabus, a module in Object-Oriented Programming contained Design Pattern. So, I give a shot and tried to learn those things.
These are some of the coolest things I learned in my learning period. So, I wanted to share it with you. I made this as a series of articles to explain one pattern in a single post.
I hope you will like the series. If you have any confusion or if I have written anything wrong please leave a comment. This will help both of us.
What are Design Patterns?
In software engineering, a software design pattern is a general, reusable solution to a commonly occurring problem within a given context in software design.
It is not a finished design that can be transformed directly into source or machine code. Rather, it is a description or template for how to solve a problem that can be used in many different situations. Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.
Yeah, I hope you had a better explanation from the above description.
Design Patterns are nothing but a general, reusable solution to commonly occurring problems in software design. Commonly occurring problems would be said something like You are designing an application, and you may have stuck at someplace to choose in which way to connect the classes and objects you have created. At this juncture, there are proved and tested and succeeded patterns called “Design Patterns” which may help you to develop the system design. Each pattern in this Design Pattern handles different cases and gives you a solution to solve.
Patterns originated as an architectural concept by Christopher Alexander as early as 1966. In 1987, Kent Beck and Ward Cunningham began experimenting with the idea of applying patterns to programming.
Design patterns gained popularity in computer science after the book Design Patterns: Elements of Reusable Object-Oriented Software was published in 1994 by the so-called “Gang of Four” (Gamma et al.), which is frequently abbreviated as “GoF”
- These were taken from Wikipedia to get a big picture behind what is Design Pattern.
So, why do we have to waste time?
Let's dive into Design Patterns one-by-one and take coding experience by solving.
Design Patterns were grouped into 3 types according to their functionality by GoF
- Creational: Involve object initialization and provide a way to decouple the client from the objects it needs to instantiate.
- Structural: Lets you compose classes or objects into larger structures.
- Behavioral: Concerned with how classes and objects interact or distribute responsibility.
Followings are the Design Patterns covered under these 3 types
- Abstract Factory
- Factory Method
- Chain of Responsibility
- Template Method
In the next article, We can start with the Singleton Design Pattern.