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

An analogous real-world example of the Acyclic Visitor pattern is a museum guide system. Imagine a museum with various exhibits like paintings, sculptures, and historical artifacts. The museum has different types of guides (audio guide, human guide, virtual reality guide) that provide information about each exhibit. Instead of modifying the exhibits every time a new guide type is introduced, each guide implements an interface to visit different exhibit types. This way, the museum can add new types of guides without altering the existing exhibits, ensuring that the system remains extensible and maintainable without forming any dependency cycles.


iluwatarAbout 3 minBehavioralDecouplingExtensibilityInterfaceObject composition
Bytecode

Intent

Allows encoding behavior as instructions for a virtual machine.

Explanation

Real world example

An analogous real-world example of the Bytecode design pattern can be seen in the process of translating a book into multiple languages. Instead of directly translating the book from the original language into every other language, the book is first translated into a common intermediate language, like Esperanto. This intermediate version is easier to translate because it is simpler and more structured. Translators for each target language then translate from Esperanto into their specific languages. This approach ensures consistency, reduces errors, and simplifies the translation process, similar to how bytecode serves as an intermediate representation to optimize and facilitate the execution of high-level programming languages across different platforms.


iluwatarAbout 4 minBehavioralAbstractionCode simplificationEncapsulationGame programmingPerformanceRuntime
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 minBehavioralDecouplingEvent-drivenGang of FourMessaging
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 3 minBehavioralClient-serverSession managementState trackingWeb 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 minBehavioralAccumulationData processingData transferGeneric
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 minBehavioralDecouplingExtensibilityGang of FourUndo
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
  • Encapsulate Context

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 3 minBehavioralContextDecouplingEncapsulationSession management
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 4 minBehavioralData accessDecouplingDomainObject mappingPersistence
Delegation

Also known as

  • Helper
  • Surrogate

Intent

To allow an object to delegate responsibility for a task to another helper object.

Explanation

Real-world example

In a restaurant, the head chef delegates tasks to sous-chefs: one manages grilling, another handles salads, and a third is in charge of desserts. Each sous-chef specializes in their area, allowing the head chef to focus on overall kitchen management. This mirrors the Delegation design pattern, where a main object delegates specific tasks to helper objects, each expert in their domain.


iluwatarAbout 2 minBehavioralDecouplingDelegationObject composition