Explain SOLID principle
Explain Singleton pattern
Singleton pattern restricts the instantiation of a class and ensures that only one instance of the class exists in the java virtual machine.
It is from the Creational Design Pattern category.
It is used for logging, drivers objects, caching and thread pool.
– singleton criticism => it introduces a global state into an application, often unnecessary
Explain the Factory pattern
The factory design pattern is used when we have a superclass with multiple sub-classes and based on input, we need to return one of the sub-class.
Explain the composite pattern
When we need to create a structure in a way that the objects in the structure has to be treated the same way, we can apply composite design pattern. Let’s understand it with a real-life example - A diagram is a structure that consists of Objects such as Circle, Lines, Triangle etc. When we fill the drawing with color (say Red), the same color also gets applied to the Objects in the drawing. Here drawing is made up of different parts and they all have same operations. Composite Pattern consists of following objects.
From the “Structural Design Patterns”
Explain decorator pattern
Decorator design pattern is used to modify the functionality of an object at runtime. At the same time other instances of the same class will not be affected by this, so individual object gets the modified behavior.
From the “Structural Design Patterns”
Explain strategy pattern
Strategy pattern is also known as Policy Pattern. We define multiple algorithms and let client application pass the algorithm to be used as a parameter.
Strategy design pattern is one of the behavioral design pattern. Strategy pattern is used when we have multiple algorithm for a specific task and client decides the actual implementation to be used at runtime.
Explain some object design patterns that are used in JS nowadays
https://www.youtube.com/watch?v=tv-_1er1mWI&ab_channel=Fireship