Design Patterns Guide

Welcome to the Design Patterns Guide — a comprehensive visual reference for the 23 Gang of Four (GoF) design patterns. Each pattern includes UML class diagrams and code examples in C#, Delphi, and C++.

Quick Reference

Category Pattern Intent
Creational Factory Method Define an interface for creating objects, letting subclasses decide which class to instantiate
  Abstract Factory Create families of related objects without specifying concrete classes
  Builder Separate construction of a complex object from its representation
  Prototype Create new objects by cloning an existing instance
  Singleton Ensure a class has only one instance with a global access point
Structural Adapter Convert the interface of a class into another interface clients expect
  Bridge Decouple an abstraction from its implementation
  Composite Compose objects into tree structures for part-whole hierarchies
  Decorator Attach additional responsibilities to an object dynamically
  Facade Provide a unified interface to a set of interfaces in a subsystem
  Flyweight Use sharing to support large numbers of fine-grained objects
  Proxy Provide a surrogate or placeholder for another object
Behavioral Chain of Responsibility Pass a request along a chain of handlers
  Command Encapsulate a request as an object
  Iterator Access elements of a collection sequentially without exposing its structure
  Mediator Define an object that encapsulates how a set of objects interact
  Memento Capture and restore an object’s internal state
  Observer Define a one-to-many dependency between objects
  State Allow an object to alter its behavior when its internal state changes
  Strategy Define a family of algorithms, encapsulate each one, and make them interchangeable
  Template Method Define the skeleton of an algorithm, deferring some steps to subclasses
  Visitor Represent an operation to be performed on elements of an object structure
  Interpreter Define a grammar representation and an interpreter to evaluate sentences

Advanced Patterns (Modern)

Category Pattern Intent
Cloud Resilience Circuit Breaker Prevent cascading failures by stopping calls to a failing service
  Bulkhead Isolate components so one failure doesn’t sink others
  Retry with Backoff Handle transient failures by retrying with increasing delays
  Sidecar Deploy auxiliary functionality in a companion process
Concurrency Actor Model Encapsulate state in actors that communicate via async messages
  Future / Promise Represent a value that will be available asynchronously
  Reactor Demultiplex and dispatch requests via a single-threaded event loop
  Object Pool Reuse pre-allocated objects to avoid expensive creation
Data & Messaging CQRS Separate read and write models for independent optimization
  Event Sourcing Persist state as a sequence of immutable events
  Saga Coordinate distributed transactions with compensating actions
  Publish-Subscribe Broadcast messages through a broker without sender knowing receivers
DDD Bounded Context Define explicit boundaries for a domain model
  Aggregate Cluster objects into a consistency boundary with a root entity
  Anti-Corruption Layer Translate between your model and an external system’s model
  Repository Mediate between domain and data layers with a collection-like interface
Extras Dependency Injection Supply dependencies from the outside for loose coupling
  Null Object Provide a do-nothing object to eliminate null checks
  MVVM Separate UI from logic via a ViewModel with data binding
  Specification Encapsulate business rules as composable predicate objects

How This Guide Is Organized

The patterns are grouped into three categories following the original GoF classification:

Each pattern page includes:

  1. Intent — what the pattern does
  2. Problem — when to use it
  3. UML Class Diagram — visual structure using Mermaid
  4. Participants — classes and their roles
  5. How It Works — step-by-step explanation
  6. Applicability — when to use and when not to
  7. Example Code — implementations in C#, Delphi, and C++
  8. Related Patterns — connections to other patterns

Back to top

Design Patterns Guide — content is provided for educational purposes.

This site uses Just the Docs, a documentation theme for Jekyll.