Terminology of the design patterns - DeanHristov/ts-design-patterns-cheat-sheet GitHub Wiki
Design patterns - Should I know them?
Basically, the design patterns don't generate our code like some AI tools that we already have in the market instead they give us a template with a series of steps (best practices) that help us to solve particular problems productively. Those patterns are grouped mainly into three "buckets" described below and each of those groups solves commonly occurring problems separately.
Creational | Structural | Behavioral |
---|---|---|
Factory | Decorator | Command |
Abstract Factory | Adapter | Chain of Responsibility |
Builder | Facade | Observer Pattern |
Prototype | Bridge | Interpreter |
Singleton | Composite | Iterator |
Flyweight | Mediator | |
Proxy | Memento | |
State | ||
Strategy | ||
Template | ||
Visitor |
1) Creational pattern
This pattern deals with the creation of the objects. It is giving us more flexability in how and where we are instantiating (calling the "new" operator) the object. For instance, sometimes we need only one instance of the object no matter how many times we are calling it. In this case, coming to play a singleton design pattern. Another example could be when we want to create a complex object step by step avoiding constructor overloading. In this case, we could use a builder design pattern.
2) Structural pattern
This group of patterns deals with how actually the class is designed. They help us to organize the inheritance and compositions in our large structure. An example of a problem that could be solved with this group of patterns is avoiding exponential inheritances through a bridge pattern or making two incompatible pieces of code work together by using an Adapter pattern.
3) Behavioral pattern
Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects. Behavioral patterns describe not just patterns of objects or classes but also the patterns of communication between them. For instance, if we have a use case where we have to traverse elements without exposing the complexity underlying we could solve this problem through an iterator pattern or we need to add a subscription mechanism to notify multiple objects in our large structure, we could use an Observer pattern.