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?
- One product kind varies → Factory Method
- Whole family must match → Abstract Factory
- Complex object built in steps → Builder
- Many similar copies → Prototype
- Exactly one shared owner → Singleton
-
Need to fit pieces together?
-
Need to organize behavior?
- Pass request along a chain → Chain of Responsibility
- Turn requests into objects with undo → Command
- Tiny language to evaluate → Interpreter
- Walk a collection without exposing it → Iterator
- Route chat between peers → Mediator
- Snapshot and restore → Memento
- Broadcast change to followers → Observer
- Behavior follows internal status → State
- Swap one swappable step → Strategy
- Fixed skeleton, varying steps → Template Method
- Add operations over a structure → Visitor
Confused pairs
Factory Method vs Abstract Factory vs Builder
| Question | Answer |
|---|---|
| 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
| Question | Answer |
|---|---|
| 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
| Question | Answer |
|---|---|
| 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
- Solo project, simple CRUD → Layered + Monolithic.
- Growing team, one deployable → Vertical Slice + Modular Monolith.
- Swappable UI/DB/providers → Hexagonal (or Onion/Clean if domain-centric).
- UI-heavy client → MVC / MVVM / MVP per platform norms.
- Independent scaling per capability → Microservices; add Event-Driven for async flows.
- Enterprise reuse across business units → SOA with ESB governance.
- Spiky workloads, minimal ops → Serverless functions + managed backends.
- Read-heavy with complex writes → CQRS & Event Sourcing; add Event Sourcing when audit/replay matters.
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
- Read the principle’s Rationale before applying it; principles trade off against each other (e.g. DRY vs KISS, Strong vs Eventual Consistency).
- Check the Anti-pattern note to recognize misuse.
- Follow Related links to neighboring principles and canonical pattern/architecture pages.
- 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.