Visitor Pattern is one of the behavioral design pattern. Visitor pattern is used when we have to perform
an operation on a group of similar kind of Objects. With the help of visitor pattern, we can move the
operational logic from the objects to another cl
Strategy 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.
Strategy pattern is also known as Policy Pattern. We
pattern is one of the behavioral design pattern. Memento design pattern is used when we want to save
the state of an object so that we can restore later on. Memento pattern is used to implement this in such a
way that the saved state data of the object is
Singleton is one of the Gangs of Four Design patterns and comes in the Creational Design Pattern
category. From the definition, it seems to be a very simple design pattern but when it comes to
implementation, it comes with a lot of implementation concerns
1. Sometimes creational patterns are competitors: there are cases when either Prototype or Abstract
Factory could be used profitably. At other times they are complementary: Abstract Factory
might store a set of Prototypes from which to clone and
Rules of thumb
1. Behavioral patterns are concerned with the assignment of responsibilities between objects, or,
encapsulating behavior in an object and delegating requests to it.
2. Chain of responsibility, Command, Mediator, and Observer, address how yo
pattern is one of the Structural design pattern and is used when we have to represent a part-whole
hierarchy. 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 patte
Interpreter pattern is one of the behavioral design pattern and is used to defines a grammatical
representation for a language and provides an interpreter to deal with this grammar. The best example of
this pattern is java compiler that interprets the jav
Pattern is one of the behavioral design pattern, so it deals with the behaviors of objects. Mediator
design pattern is used to provide a centralized communication medium between different objects in a
system. According to GoF, mediator pattern intent is:
Prototype pattern is one of the Creational Design pattern, so it provides a mechanism of object creation.
Prototype pattern is used when the Object creation is a costly affair and requires a lot of time and
resources and you have a similar object already
Builder design pattern is a creational design pattern like Factory Pattern and Abstract Factory
Pattern. This pattern was introduced to solve some of the problems with Factory and Abstract Factory
design patterns when the Object contains a lot of attribut
Pattern is one of the Structural design patterns (such as Adapter pattern and Decorator pattern) and
used to help client applications to easily interact with the system.
According to GoF Facade design pattern is:
"Provide a unified interface to a set of i
Pattern is one of the Creational Design pattern and its widely used in JDK as well as frameworks like
Spring and Struts.
Factory design pattern is used when we have a super class with multiple sub-classes and based on input,
we need to return one of the s
Iterator pattern in one of the behavioral pattern and its used to provide a standard way to traverse
through a group of Objects. Iterator pattern is widely used in Java Collection Framework where Iterator
interface provides methods for traversing through
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
behaviour. Decorator design pattern is one of the
Proxy Design pattern is one of the Structural design pattern and in my opinion one of the simplest
pattern to understand. Proxy pattern intent according to GoF is:
"Provide a surrogate or place holder for another object to control access to it."
Command Pattern is one of the Behavioral Design Pattern and its used to implement lose coupling in
a request-response model. In command pattern, the request is send to the invoker and invoker pass it to
the encapsulated command object. Command object pass
Method is a behavioral design pattern and its used to create a method stub and deferring some of the
steps of implementation to the subclasses. Template method defines the steps to execute an algorithm
and it can provide default implementation that might
Abstract Factory is one of the Creational pattern and almost similar to Factory Pattern except the fact
that its more like factory of factories.
If you are familiar with factory design pattern in java, you will notice that we have a single Factory
Observer pattern is one of the behavioral design pattern. Observer design pattern is useful when you
are interested in the state of an object and want to get notified whenever there is any change. In observer
pattern, the object that watch on the state of
When we have interface hierarchies in both interfaces as well as implementations, then builder design
pattern is used to decouple the interfaces from implementation and hiding the implementation details
from the client programs. Like Adapter pattern, its
1. Adapter makes things work after they're designed; Bridge makes them work before they are.
2. Bridge is designed up-front to let the abstraction and the implementation vary independently.
Adapter is retrofitted to make unrelated classes work to
According to GoF, flyweight design pattern intent is:
"Use sharing to support large numbers of fine-grained objects efficiently"
Flyweight design pattern is a Structural design pattern like Facade pattern, Adapter Pattern and
Decorator pattern. Flyweight
pattern is one of the behavioral design pattern. State design pattern is used when an Object change its
behavior based on its internal state.
If we have to change the behavior of an object based on its state, we can have a state variable in the
Chain of responsibility design pattern is one of the behavioral design pattern. Chain of responsibility
pattern is used to achieve lose coupling in software design where a request from client is passed to a
chain of objects to process them. Then the objec
Patterns are very popular among software developers. A design pattern is a well described solution to a
common software problem.
Some of the benefits of using design patterns are:
Design Patterns are already defined and provides industry standard approac
Adapter design pattern is one of the structural design pattern and its used so that two unrelated
interfaces can work together. The object that joins these unrelated interface is called an Adapter. As a
real life example, we can think of a mobile charger