Design Patterns

Open closed principle

Last Updated:

The open/closed principle (OCP) states that a module should be open to extension but closed for modification. It is one of famous 5 solid principles …

Single responsibility principle

Last Updated:

The single responsibility principle (SRP) states that a software component (in general, a class) must have only one responsibility. The fact that the class has a sole responsibility means that it is in charge of doing just one concrete thing, and as a consequence of that, we can conclude that it must have only one reason to change. It is one of 5 famous SOLID principles.

State Design Pattern

Last Updated:

The state pattern is a behavioral design pattern. According to GoF definition, a state allows an object to alter its behavior when its internal state …

Mediator Design Pattern

Last Updated:

Mediator helps in establishing loosely coupled communication between objects and helps in reducing the direct references to each other.

Observer Design Pattern

Last Updated:

According to GoF definition, observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and …

Memento Design Pattern

Last Updated:

Memento design pattern is behavioral pattern and one of 23 design patterns discussed by Gang of Four. Memento pattern is used to restore state of …

Iterator Design Pattern

Last Updated:

An iterator design pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Proxy Design Pattern

Last Updated:

According to GoF definition of proxy design pattern, a proxy object provide a surrogate or placeholder for another object to control access to it. A …

Flyweight Design Pattern

Last Updated:

As per GoF definition, flyweight design pattern enables use sharing of objects to support large numbers of fine-grained objects efficiently. A flyweight is a shared …

Facade Design Pattern

Last Updated:

Facade design pattern provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use.

Command Design Pattern

Last Updated:

Command pattern is a behavioral design pattern which is useful to abstract business logic into discrete actions i.e. commands. It motivates loose coupling.

Strategy Design Pattern

Last Updated:

Strategy design pattern is behavioral design pattern where we choose a specific implementation of algorithm or task in run time – out of multiple other implementations for same task.

Template Method Design Pattern

Last Updated:

Template method design pattern is widely accepted behavioral design pattern to enforce some sort of algorithm (fixed set of steps) in the context of programming. …

Composite Design Pattern

Last Updated:

Composite design pattern is a structural pattern which modifies the structure of an object. This pattern is most suitable in cases where you need to …

Bridge Design Pattern

Last Updated:

Bridge design pattern is used to decouple a class into two parts – abstraction and it’s implementation – so that both can evolve in future …

Adapter Design Pattern in Java

Last Updated:

Ever tried to use a your camera memory card in your laptop. You cannot use it directly simply because there is no port in laptop …

Builder Design Pattern in Java

Last Updated:

The builder pattern, as name implies, is an alternative way to construct complex objects. This pattern should be used when we want to build different …

Decorator Design Pattern in Java

Last Updated:

In software engineering, decorator design pattern is used to add additional features or behaviors to a particular instance of a class, while not modifying the …

Visitor Design Pattern Example

Last Updated:

Design patterns are used to solve the problems which occur in a pattern, we all know that, right? Also we know that behavioral design patterns …

Chain of Responsibility Design Pattern

Last Updated:

The Chain of Responsibility is known as a behavioral pattern. The main objective of this pattern is that it avoids coupling the sender of the …

HowToDoInJava

A blog about Java and its related technologies, the best practices, algorithms, interview questions, scripting languages, and Python.