Skip to content

patterns-reference

Quick reference for common patterns with usage guidance.

PatternWhen to UseWhen NOT to UseComplexity
Active RecordSimple CRUD, rapid prototypingComplex queries, multiple sourcesLow
RepositoryTesting needed, multiple sourcesSimple CRUD, single databaseMedium
Unit of WorkComplex transactionsSimple operationsHigh
Data MapperComplex domain, performanceSimple CRUD, rapid devHigh
PatternWhen to UseWhen NOT to UseComplexity
Transaction ScriptSimple CRUD, proceduralComplex business rulesLow
Table ModuleRecord-based logicRich behavior neededLow
Domain ModelComplex business logicSimple CRUDMedium
DDD (Full)Complex domain, domain expertsSimple domain, no expertsHigh
PatternWhen to UseWhen NOT to UseComplexity
Modular MonolithSmall teams, unclear boundariesClear contexts, different scalesMedium
MicroservicesDifferent scales, large teamsSmall teams, simple domainVery High
Event-DrivenReal-time, loose couplingSimple workflows, strong consistencyHigh
CQRSRead/write performance divergesSimple CRUD, same modelHigh
SagaDistributed transactionsSingle database, simple ACIDHigh
PatternWhen to UseWhen NOT to UseComplexity
RESTStandard CRUD, resourcesReal-time, complex queriesLow
GraphQLFlexible queries, multiple clientsSimple CRUD, caching needsMedium
gRPCInternal services, performancePublic APIs, browser clientsMedium
WebSocketReal-time updatesSimple request/responseMedium

“Start simple, add complexity only when proven necessary.”

  • You can always add patterns later
  • Removing complexity is MUCH harder than adding it
  • When in doubt, choose simpler option