Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Selection Guide

Part of the unified study index: Home. Canonical chooser for all three pillars — patterns, architecture, and principles. Category overviews link here instead of keeping competing tables.

Start from your problem, then narrow to 2-3 candidates.

1. Patterns

By problem type

  • Need to create objects without naming exact classes?

  • Need to fit pieces together?

    • Incompatible interfaces → Adapter
    • Abstraction vs implementation vary separately → Bridge
    • Tree of wholes and parts → Composite
    • Add responsibilities at runtime → Decorator
    • Simplify a subsystem → Facade
    • Many similar small objects → Flyweight
    • Control access or defer cost → Proxy
  • Need to organize behavior?

Confused pairs

Factory Method vs Abstract Factory vs Builder

QuestionAnswer
How many kinds per call?Factory Method: one. Abstract Factory: a family. Builder: one complex object over steps.
When to choose Factory Method?One flow, product kind varies.
When to choose Abstract Factory?Parts must match (theme, platform).
When to choose Builder?Assembly needs order + validation.

Adapter vs Facade vs Proxy

QuestionAnswer
What problem?Adapter: wrong interface. Facade: too complex. Proxy: control access.
When Adapter?Wrap one existing type to fit a new contract.
When Facade?One simple call drives many subsystem calls.
When Proxy?Same interface, but lazy, cached, or guarded.

Strategy vs State vs Template Method

QuestionAnswer
Who picks the variant?Strategy: caller injects. State: object transitions itself. Template Method: subclass fills a step.
When Strategy?Runtime choice among peer algorithms.
When State?Behavior must track status lifecycle.
When Template Method?Skeleton fixed, one step varies by subclass.

2. Architecture

Canonical decision guidance for the architecture tutorial. The tutorial keeps the full comparison tables; this section is the quick router.

By situation

Combinations are normal: e.g., Clean inside a Modular Monolith module, or Vertical Slices each exposing ports, or Microservices communicating via events with CQRS on the hot path.

Confused pairs (summary — full tables in the tutorial)

  • Hexagonal vs Onion vs Clean: ports/adapters vs domain-centered rings vs entities+use-cases rings. Choose Hexagonal when swapping infrastructure matters most; Onion/Clean when domain purity or rule enforcement matters most.
  • Layered vs Vertical Slice: technical layers vs feature slices. Choose Vertical Slice when features evolve independently.
  • Modular Monolith vs Microservices: one deployable with enforced module boundaries vs many independently deployable services. Choose the monolith first; extract when scaling or deploy independence outweighs ops cost.
  • Event-Driven vs CQRS & Event Sourcing: broker-decoupled reactions vs read/write separation with an immutable event log. Choose the latter when reads and writes scale differently or audit/replay matters.

3. Principles

How to use the 110-principle catalog without reading it cover to cover.

By problem type

  • Designing a class or module? Start with SOLID (1–5) and General Design (6–20): SRP, OCP, DRY, Composition over Inheritance, Program to an Interface.
  • Structuring the codebase? See Architecture (21–33): Dependency Rule, Modularity, Bounded Context.
  • Going distributed? See Distributed Systems (34–52): CAP, Idempotency, Retry with Backoff, Circuit Breaker — pair with Event-Driven and Microservices.
  • Worried about speed or resources? See Performance (53–61): Premature Optimization, Bounded Resource, Batch Processing.
  • Handling auth, input, or secrets? See Security (62–69): Zero Trust, Least Privilege, Fail Securely.
  • Writing tests? See Testing (70–77): Test Pyramid, FIRST, Test Isolation.
  • Designing an API or message format? See API (78–84): Postel’s Law, Backward Compatibility, SemVer.
  • Improving delivery? See Development (85–92): Small Batch, Automation First, SSOT.
  • Working functionally or on the BEAM? See Functional (93–100) and BEAM/OTP (101–110): Immutability, Let It Crash, Supervision Trees.

How to apply

  1. Read the principle’s Rationale before applying it; principles trade off against each other (e.g. DRY vs KISS, Strong vs Eventual Consistency).
  2. Check the Anti-pattern note to recognize misuse.
  3. Follow Related links to neighboring principles and canonical pattern/architecture pages.
  4. When a principle summarizes an architecture pattern (Hexagonal, Clean, Onion, CQRS, Event Sourcing), follow its link to the canonical architecture/ page for the full treatment.