The Gang of Four (GoF) design patterns (Gamma, Helm, Johnson, Vlissides, 1994) catalog 23 reusable object-oriented design solutions in three categories: Creational (object instantiation), Structural (object composition), and Behavioral (object communication). These patterns form a shared vocabulary for engineers — saying "use a Factory Method here" communicates more precisely and concisely than describing the pattern from scratch. In distributed systems and microservices, a second generation of patterns has emerged: Circuit Breaker, Bulkhead, Retry, Saga, and Outbox — these address the failure modes specific to networked communication that the GoF (1994) did not anticipate.

Key Points

  • Creational patterns — Factory Method, Abstract Factory, Builder, Singleton, Prototype — address "how do we create objects?" Builder is heavily used for complex configuration objects (HTTP clients, database connections).
  • Structural patterns — Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy — address "how do we compose objects?" Proxy underlies AOP, lazy loading, and service mesh sidecars.
  • Behavioral patterns — Chain of Responsibility, Command, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method, Visitor — address "how do objects communicate?" Observer is the foundation of all event-driven programming.
  • Singleton is frequently cited as an anti-pattern in distributed/microservices contexts — singletons in stateless containers are fine, but singletons relying on in-process state break in multi-instance deployments.
  • Strategy pattern enables runtime algorithm selection without conditionals — used in pricing engines (different discount strategies), sorting (pluggable comparators), and payment processing (card vs. crypto vs. BNPL).
  • Decorator pattern adds behavior without inheritance — Java I/O streams, Python decorators, and HTTP middleware chains all implement this pattern for cross-cutting concerns.
  • Observer pattern = publish/subscribe at the object level; in distributed systems it scales to Kafka topics, Redis pub/sub, and WebSocket broadcast — same pattern, different transport.
  • Command pattern encapsulates requests as objects — enables undo/redo, request queuing, audit logging, and macro recording; underpins event sourcing's "commands produce events" model.

Real-World Example

Spring Framework's entire dependency injection container is the Factory pattern at scale; its AOP (Aspect-Oriented Programming) is the Proxy + Decorator pattern combination. Understanding GoF patterns explains why Spring's `@Transactional` annotation injects a proxy around your bean — it is GoF Proxy pattern creating a transactional wrapper, not magic.