History of Design Patterns
In the programming world, the concept of design patterns isn’t old. However, it was formulated back in 1994 for the first time and that too, when an influential book “Design Patterns: Elements Of Reusable Object-Oriented Software” was published.
Interestingly, in this book, almost 23 object-oriented design patterns were mentioned:
The authors who produced this exceptional work are named as follows:
Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides – a group that became popular later with the title Gang of Four (GoF).
Design Patterns and their Structure
Henceforth, notably, when you implement the same pattern to the two codes directing to two different scenarios, it reverses back to two different results.
It’s simple! Whenever the same solution is repeated over and over again, you will recognize it eventually and name it by further describing the solution.
Note: Most often, design patterns are muddled up with algorithms.
Design Patterns Structures
Practically, the documentation template structure contains the following parts:
Intent – it briefs about the functionality of the pattern; including the problem and solution.
Motivation – the detailed overview of how the pattern will solve the problem by providing resourceful solutions.
Structure – It makes visual understanding of the pattern super feasible by showing certain classes and objects.
Code – the example code of any programming language is quoted so a reader can grasp the idea instantly.
Flexibility with programming styles – This is one of the patterns in JS that supports object-oriented, procedural, and functional programming styles.
Enables first-class functions – Functions (act like a variable) and are passed on as arguments expediently.
- Creational design pattern
Some of the design patterns in JS, that fall under this category are Factory, Prototype, Constructor, and Singleton.
- Structural design pattern
For these patterns in JS, the concerned part is object composition. The facile ways are explained through these design patterns in order to organize classes and objects into giant structures.
They ensure that the system and its structure perform efficiently and flexibly while a certain part of the system is changed; it doesn’t affect the entire structure of the system though.
- Behavioral design pattern
The patterns that are part of this category are Command, Observer, Template, Strategy, Iterator, and Chain of Responsibility.
We suggest all other developers use these JS design patterns in their development strategies.