Skip to main content
Acyclic Visitor

Intent

The Acyclic Visitor pattern decouples operations from an object hierarchy, allowing you to add new operations without modifying the object structure directly.

Explanation

Real world example

We have a hierarchy of modem classes. The modems in this hierarchy need to be visited by an external algorithm based on filtering criteria (is it Unix or DOS compatible modem).


iluwatarAbout 2 minBehavioralDecouplingExtensibility
Bytecode

Intent

Allows encoding behavior as instructions for a virtual machine.

Explanation

Real world example

A team is working on a new game where wizards battle against each other. The wizard behavior needs to be carefully adjusted and iterated hundreds of times through playtesting. It's not optimal to ask the programmer to make changes each time the game designer wants to vary the behavior, so the wizard behavior is implemented as a data-driven virtual machine.


iluwatarAbout 4 minBehavioralGame programming
Chain of responsibility

Also known as

  • Chain of Command
  • Chain of Objects
  • Responsibility Chain

Intent

Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it.


iluwatarAbout 3 minBehavioralGang of FourDecoupling
Client Session

Also known as

  • User session

Intent

The Client Session design pattern aims to maintain a user's state and data across multiple requests within a web application, ensuring a continuous and personalized user experience.

Explanation

Real-World Example


iluwatarAbout 2 minBehavioralSession managementWeb development
Collecting Parameter

Also known as

  • Collector
  • Accumulator

Intent

Aims to simplify methods that collect information by passing a single collection object through various method calls, allowing them to add results to this collection rather than each method creating its own collection.


iluwatarAbout 4 minBehavioralAccumulationGeneric
Command

Also known as

  • Action
  • Transaction

Intent

The Command design pattern encapsulates a request as an object, thereby allowing for parameterization of clients with queues, requests, and operations. It also allows for the support of undoable operations.


iluwatarAbout 3 minBehavioralGang of Four
Commander

Also known as

  • Distributed Transaction Commander
  • Transaction Coordinator

Intent

The intent of the Commander pattern in the context of distributed transactions is to manage and coordinate complex transactions across multiple distributed components or services, ensuring consistency and integrity of the overall transaction. It encapsulates transaction commands and coordination logic, facilitating the implementation of distributed transaction protocols like two-phase commit or Saga.


iluwatarAbout 3 minBehavioralCloud distributedMicroservicesTransactions
Context Object

Also known as

  • Context
  • Context Encapsulation
  • Context Holder

Intent

Encapsulate the context (state and behaviors) relevant to the user or the request being processed in order to decouple application components from the complexities of the environment.


iluwatarAbout 2 minBehavioralContextDecouplingEncapsulation
Data Bus

Also known as

  • Event Bus
  • Message Bus

Intent

The Data Bus design pattern aims to provide a centralized communication channel through which various components of a system can exchange data without being directly connected, thus promoting loose coupling and enhancing scalability and maintainability.


iluwatarAbout 3 minBehavioralDecouplingEvent-drivenMessagingPublish/subscribe
Data Mapper

Also known as

  • Object-Relational Mapping (ORM)

Intent

The Data Mapper pattern aims to create an abstraction layer between the database and the business logic, allowing them to evolve independently. It maps data from the database objects to in-memory data structures and vice versa, minimizing direct dependencies between the application's core logic and the underlying database structure.


iluwatarAbout 3 minBehavioralData accessDecouplingObject mappingPersistence