Contact Me

Design Patterns

Design patterns are a set of typical solutions to commonly occurring problems in software development.


The classical design patterns are divided into 3 types:





Creationals


Factory

 Used when we have a superclass with multiple sub-classes and based on input, we need to return one of the sub-class.

Abstract Factory

 Almost similar to Factory Pattern except the fact that its more like factory of factories.

Builder

 Solves the issue with large number of optional parameters and inconsistent state.

Prototype

 Provides a mechanism to copy the original object to a new object and then modify it according to our needs.

Singleton

 Lets you ensure that a class has only one instance, while providing a global access point to this instance.




Structurals


Adapter

 Its used so that two unrelated interfaces can work together. The object that joins these unrelated interface is called an Adapter.

Bridge

 Is used to decouple the interfaces from implementation and hiding the implementation details from the client programs.

Composite

 Lets you compose objects into tree structures and then work with these structures as if they were individual objects.

Decorator

 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.

Facade

 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.

Flyweight

 Use sharing to support large numbers of fine-grained objects efficiently (when we need to create a lot of Objects of a class).

Proxy

 It provides a surrogate or placeholder for another object to control access to it.




Behaviorals


Chain of Responsiblity

 Used to achieve loose coupling in software design where a request from client is passed to a chain of objects to process them.

Command

 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.

Iterator

 rovides a way to access the elements of an aggregate object without exposing its underlying represenation by hiding the actual implementation of traversal.

Mediator

 Used to provide a centralized communication medium between different objects in a system, restricting communications between objects.

Memento

 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.

Observer

 Lets you define a subscription mechanism to notify multiple objects about any events that happen to the object they’re observing.

State

 Used when an Object change its behavior based on its internal state. It appears as if the object changed its class.

Strategy

 Lets you define a family of algorithms, put each of them into a separate class, and make their objects interchangeable.

Template Method

 Used to create a method stub and deferring some of the steps of implementation to the subclasses.

Visitor

 Used when we have to perform an operation on a group of similar kind of Objects.