Home » Tag Archives: Design Patterns

Tag Archives: Design Patterns

Strategy Design Pattern In Java

The strategy design pattern is a behavioral pattern in which we have multiple algorithms/strategies for achieving a task and which algorithm/strategy to use is left for the client to choose. The various algorithm options are encapsulated in individual classes. In this tutorial, we’ll learn to implement the strategy design pattern in Java. UML Representation: Let’s first start by looking at ...

Read More »

Mediator Design Pattern In Java

In this tutorial, we’ll learn about a behavioral pattern that promotes loose coupling between several objects communicating with one another. The idea behind the Mediator design pattern is to have a central object that encapsulates how a set of objects interact. In the mediator pattern, we extract all the relationships between different classes in a separate class known as a ...

Read More »

Chain Of Responsibility Design Pattern In Java

In this tutorial, we’ll learn how to implement the Chain Of Responsibility Pattern in Java. The Chain Of Responsibility design pattern involves having a chain of objects that are together responsible for handling a request. When a client sends a request, the first handler will try to process it. If it can process it, then the request processing ends here. ...

Read More »

Command Design Pattern In Java

In this tutorial, we’ll learn about the command pattern which is an important behavioral design pattern. It has some important applications like implementing undo/redo functionality in text editors. In the command design pattern, there’s a command object that sits between the sender and the receiver objects. The sender object can create a command object. The command object then calls the ...

Read More »

State Design Pattern In Java

In this tutorial, we’ll explore another popular behavioral design pattern – the State Design Pattern. The knowledge of state design pattern comes handy when we’re working with an object which can exist in multiple states. We should use it primarily when the behavior of an object depends on its current state. This pattern helps us avoid long conditional checks of ...

Read More »

Observer Design Pattern In Java

In this tutorial, we’ll talk about the Observer design pattern. There are two main aspects to the observer pattern – a Subject and the Observers. We use this pattern when our system has multiple objects, known as the observers, relying on the state of one particular object – the subject. All the observers register themselves to the subject. Whenever there ...

Read More »

Decorator Design Pattern In Java

A decorator design pattern allows dynamically attaching the additional responsibilities or behaviors to an object at runtime. It is a structural pattern and makes use of aggregation to combine those behaviors. In this tutorial, we’ll learn to implement the decorator pattern. UML Diagram: Let’s start by looking at the UML representation of a decorator pattern: The ConcreteComponent class is the ...

Read More »

Proxy Design Pattern In Java

Proxy objects or the surrogates provide a placeholder for another object to control access to that object. A proxy acts as a lightweight or the simplified version of the original object. It supports the same operations as the original object but may delegate those requests to the original object to achieve them. The Proxy design pattern is a structural pattern ...

Read More »

Factory Method Design Pattern

Factory Method pattern is one of the popular creational design patterns. It doesn’t specifically rely on a factory object to create the objects. Rather, the idea is to use a separate method in the same class to create an object. Factory Method pattern defines an interface for creating objects but lets the subclasses decide how to instantiate its objects. Each ...

Read More »