Design Patterns has nothing to do with algorithms or programming constructs/concepts (like loops, big-o complexity, etc). Instead, Design Patterns guide you to structure the classes and how they should collaborate.
The goal of embracing Design Patterns is to “Design resuable and extensible object oriented software”.
It is mandatory that every software engineer/programmer should have mastery over Design Patterns.
Design Patterns are solutions to a commonly occurring problem.
For example, Undo/Redo is definitely a feature that we implement in almost every application. What’s the most elegant solution to solve this in any application? Well, the answer lies in Design Patterns.
The Design Patterns are documented in the famous book called “Elements of Resuable Object-Oriented Software” by GoF (Gang of Four). Gang of Four are the 4 authors namely Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. The GoF divided the set of 23 design patterns into 3 categories.
- Creational Patterns – focus on how to create objects
- Structural Patterns – focus on the relationship between the objects
- Behavioural Patterns – focus on interaction/communication between the objects
Also note that 23 design patterns are the officially documented ones or the classic ones that everybody in the programming world should know. You might come across many unofficial patterns recommended by companies for their products/platforms. So, remember that 23 is not a fixed number in terms of design patterns in the whole world.
The biggest advantage of Design Patterns are:
- It helps to communicate with other developers at a more abstract level. By just referring to the name of the Pattern, developers would understand what we are communicating to them.
- You don’t have to write a lot of code to express the idea.
- It makes you a better designer because you always think in terms of objects, re-usability and extensibility.
- Not matter what the programming language, it helps you design solutions.
- It helps you use new frameworks & libraries faster because your mind knows how to understand patterns.