Design patterns are a set of typical solutions to commonly occurring problems in software development.
The classical design patterns are divided into 3 types:
Used when we have a superclass with multiple sub-classes and based on input, we need to return one of the sub-class.
Almost similar to Factory Pattern except the fact that its more like factory of factories.
Solves the issue with large number of optional parameters and inconsistent state.
Provides a mechanism to copy the original object to a new object and then modify it according to our needs.
Lets you ensure that a class has only one instance, while providing a global access point to this instance.
Its used so that two unrelated interfaces can work together. The object that joins these unrelated interface is called an Adapter.
Is used to decouple the interfaces from implementation and hiding the implementation details from the client programs.
Lets you compose objects into tree structures and then work with these structures as if they were individual objects.
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.
Provide a unified interface to a set of interfaces in a subsystem. Facade Pattern defines a higher-level interface that makes the subsystem easier to use.
Use sharing to support large numbers of fine-grained objects efficiently (when we need to create a lot of Objects of a class).
It provides a surrogate or placeholder for another object to control access to it.
Used to achieve loose coupling in software design where a request from client is passed to a chain of objects to process them.
Turns a request into a stand-alone object that contains all information about the request, used to implement loose coupling in a request-response model.
rovides a way to access the elements of an aggregate object without exposing its underlying represenation by hiding the actual implementation of traversal.
Used to provide a centralized communication medium between different objects in a system, restricting communications between objects.
It allows an object's internal state to be saved and restored at a later time, while keeping the object's class and its interface separate from the details of its state.
Lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing.
Used when an Object change its behavior based on its internal state. It appears as if the object changed its class.
Lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.
Used to create a method stub and deferring some of the steps of implementation to the subclasses.
Used when we have to perform an operation on a group of similar kind of Objects.