Command Design Pattern in Java

Command Pattern The command pattern comes under behavioral design pattern. The Command design pattern is used to create objects that represent actions and events in an application. In the command pattern, a command interface declares a method for executing a particular action. A command object encapsulates an action or event and contains all information required to understand the action or…

Chain of Responsibility Design Pattern in Java

The Chain of Responsibility is known as a behavioral pattern, as it is used to manage algorithms, relationships and responsibilities between objects. The Chain of Responsibility pattern consists of a series of processing objects where each object containing the type of commands it can handle. Each object in the series either does its own task or passes to the next…

Proxy Design Pattern In Java

Table of Contents Introduction Use Cases Proxy Pattern Example Proxy Pattern Class Diagram Prerequisites Project Setup Proxy Interface Proxy Implementation Proxy Class Service Class Proxy Example Source Code Introduction The Proxy is known as a structural pattern, as it is used to form large object structures across many disparate objects. It functions as an interface to something else such as…

Facade Design Pattern in Java

This design pattern comes under structural pattern as this pattern adds an interface to the existing system to hide all its complexities. As the name suggests Facade means the face of the building block. The real life examples of this pattern can be explained as explained below : We know that Computer system starts up when we push a start…

Flyweight Design Pattern in Java

Flyweight Pattern is a structural pattern as it is used to form large object structures across many disparate objects. This pattern minimizes memory use by sharing as much data as possible with other similar objects. This pattern increases performance by avoid creating a large number of expensive objects and instead reusing the existing instances to represent new ones.

Decorator Design Pattern in Java

This is one of the structural design patterns. This pattern acts as a wrapper to the existing class. The Decorator pattern lets us attach additional responsibilities and modify an instance functionality dynamically without affecting the original object or other objects. Decorators provide a flexible alternative to subclassing for extending functionality, using composition instead of inheritance.

Composite Design Pattern in Java

The composite pattern is a structural design pattern. This pattern is also called a partitioning pattern. This pattern explains that a group of objects will be treated as a same way as a single instance of an object. The intention of the composite pattern is to compose objects into tree hierarchies to represent the part-whole relationship. In composite pattern, the…

Bridge Design Pattern in Java

One of the structural patterns, the Bridge Pattern, decouples an abstraction from its implementation so that two can vary independently. The bridge uses encapsulation, aggregation and also it can use inheritance to separate responsibilities into different classes. The Bridge Pattern can be thought of as two layers of abstraction. This pattern involves an interface which acts as a bridge which…

Adapter Design Pattern in Java

Adapter pattern – one of the structural patterns – bridges the gap between two incompatible interfaces. This means that we can make classes work together that cannot otherwise because of incompatible interfaces. There are two approaches for implementing Adapter Pattern – class adapter and object adapter, however both approaches produce the same result. A class adapter uses multiple inheritance (by…

Prototype Design Pattern in Java

Prototype pattern refers to creation of new objects through cloning of the existing objects. This type of design pattern comes under creational pattern as this pattern provides one of the best way to create an object. By creating a prototype, new objects are created by copying this prototype. This pattern is used when creation of object directly is costly. For…