By Problem Type
```
CREATING OBJECTS
βββ Complex/conditional creation βββββββββββ Factory Method
βββ Families of related objects ββββββββββββ Abstract Factory
βββ Step-by-step construction ββββββββββββββ Builder
βββ Clone existing objects βββββββββββββββββ Prototype
βββ Single instance needed βββββββββββββββββ Singleton (use sparingly!)
STRUCTURING/COMPOSING OBJECTS
βββ Incompatible interface βββββββββββββββββ Adapter
βββ Simplify complex subsystem βββββββββββββ Facade
βββ Tree/hierarchy structure βββββββββββββββ Composite
βββ Add behavior dynamically βββββββββββββββ Decorator
βββ Control access to object βββββββββββββββ Proxy
MANAGING COMMUNICATION/BEHAVIOR
βββ One-to-many notification βββββββββββββββ Observer
βββ Encapsulate requests as objects ββββββββ Command
βββ Behavior varies by internal state ββββββ State
βββ Swap algorithms at runtime βββββββββββββ Strategy
βββ Algorithm skeleton with hooks ββββββββββ Template Method
βββ Reduce N-to-N communication ββββββββββββ Mediator
βββ Sequential handlers ββββββββββββββββββββ Chain of Responsibility
MANAGING DATA ACCESS
βββ Abstract data source βββββββββββββββββββ Repository
βββ Track changes for atomic commit ββββββββ Unit of Work
βββ Ensure object identity βββββββββββββββββ Identity Map
βββ Defer expensive loading ββββββββββββββββ Lazy Load
βββ Map objects to database ββββββββββββββββ Data Mapper
βββ Shape data for transfer ββββββββββββββββ DTO
```
By Symptom
| Symptom | Consider |
|---------|----------|
| Giant switch/if-else on type | Strategy, State, or polymorphism |
| Duplicate code across classes | Template Method, Strategy |
| Need to notify many objects of changes | Observer |
| Complex object creation logic | Factory, Builder |
| Adding features bloats class | Decorator |
| Third-party API doesn't fit your code | Adapter |
| Too many dependencies between components | Mediator, Facade |
| Can't test without database/network | Repository, Dependency Injection |
| Need undo/redo | Command |
| Object behavior depends on state | State |
| Request needs processing by multiple handlers | Chain of Responsibility |
Domain Logic: Transaction Script vs Domain Model
| Factor | Transaction Script | Domain Model |
|--------|-------------------|--------------|
| Logic complexity | Simple (< 500 lines) | Complex, many rules |
| Business rules | Few, straightforward | Many, interacting |
| Operations | CRUD-heavy | Rich behavior |
| Team/timeline | Small team, quick delivery | Long-term maintenance |
| Testing | Integration tests | Unit tests on domain |
Rule of thumb: Start with Transaction Script. Refactor to Domain Model when procedural code becomes hard to maintain.