6.1 · Style vs pattern
The distinction was sharpened by Mary Shaw and David Garlan in Software Architecture: Perspectives on an Emerging Discipline (1996). A style describes the topology and interaction rules at the whole-system level — components, connectors, constraints. A pattern solves a recurring design problem in a context — usually below the system level. A system has one primary style (with possibly a secondary style nested inside) but contains dozens of patterns. "Microservices" is a style; "circuit breaker" is a pattern used inside it.
| Aspect | Style | Pattern |
|---|---|---|
| Scope | Whole system | Component / interaction |
| Cardinality | Usually one primary | Many, layered |
| Drives | Deployment, topology, qualities | Class-level structure, control flow |
| Catalog | Bass/Clements, Richards/Ford, ISO/IEC/IEEE 42010 | GoF, PoEAA, EIP, Cloud Design Patterns |
6.2 · Catalog of architecture styles
| Style | Defining trait | Sweet spot |
|---|---|---|
| Layered (n-tier) | Strict horizontal layers, downward calls only | CRUD line-of-business apps |
| Client-Server | Thick server, thin client(s) | Classic enterprise / SaaS |
| Pipes & Filters | Unidirectional dataflow through stateless filters | ETL, signal processing, compilers |
| Hexagonal / Ports & Adapters (Cockburn 2005) | Domain core, swap-able adapters at the edges | Long-lived domain logic; test isolation |
| Clean / Onion (Martin 2012 / Palermo 2008) | Concentric layers; dependency rule points inward | Same as Hexagonal, explicit use-case layer |
| Modular Monolith | One deployable, strong internal module boundaries | Small teams, high cohesion, fast change |
| Microservices | Independently deployable services around business capabilities | Many teams, divergent change cadences |
| SOA | Enterprise-scope reusable services, often over ESB | Large enterprise IT, B2B integration |
| Event-Driven (EDA) | Loose coupling via asynchronous events on a broker | Streaming, IoT, complex workflows |
| Space-Based | In-memory data grid, processing close to data | Extreme variable load (ticketing, trading) |
| Serverless / FaaS | Stateless functions, managed runtime, per-invocation billing | Spiky, event-triggered workloads |
| Microkernel (plug-in) | Tiny core + extension plug-ins | IDEs, browsers, business-rule platforms |
| Broker | Central broker dispatches between distributed nodes | Legacy MOM, CORBA, RPC bridges |
| Peer-to-Peer | No central authority; nodes equal | File sharing, blockchains, mesh |
6.3 · Deep dives
Layered
Presentation → Application → Domain → Infrastructure. Each layer depends only on the one below it (the "closed layers" rule). Cheap to staff, cheap to teach. Buys testability and maintainability; sacrifices performance (every call crosses layers) and deployability (one binary). NFR profile: + maintainability + portability – performance – scalability.
Hexagonal / Ports & Adapters
The domain is in the centre; it declares ports (interfaces). The outside world plugs in via adapters: REST adapter, Kafka adapter, Postgres adapter, test double adapter. The domain has zero knowledge of frameworks. Choose when the domain logic outlives the technology (insurance, finance, manufacturing). Avoid for thin CRUD apps where the ceremony exceeds the value. NFR profile: + testability + modifiability – time-to-market for simple cases.
Microservices
Term popularised by James Lewis & Martin Fowler (2014). Each service owns its data, is independently deployable, communicates over the network (usually HTTP/JSON, gRPC, or events). Buys independent scaling, polyglot persistence, and team autonomy. Costs: distributed-systems complexity (Fallacies of Distributed Computing — Deutsch 1994), eventual consistency, operational overhead, expensive end-to-end debugging. NFR profile: + scalability + deployability – simplicity – consistency (CAP).
Event-Driven (EDA)
Two flavours: broker topology (loose chain of consumers; e.g. NATS, RabbitMQ) and mediator topology (a central orchestrator coordinates; e.g. Camunda, Temporal). Producers do not know consumers. Buys decoupling, asynchrony, replayability (if log-based like Kafka). Costs: out-of-order delivery, idempotency burden, traceability. NFR profile: + scalability + extensibility – debuggability.
Serverless / FaaS
You write functions; the platform (AWS Lambda, Azure Functions, GCP Cloud Functions, Cloudflare Workers) provides the runtime, scaling, and billing per ms. Cold-start latency, 15-minute execution limits, vendor lock-in, and observability gaps are the recurring complaints. Sweet spot: event-triggered glue (S3-arrived → process), spiky APIs, scheduled jobs. NFR profile: + elasticity + cost-for-spiky – cold-start latency – portability.
6.4 · CQRS & Event Sourcing
CQRS (Command Query Responsibility Segregation — Greg Young, building on Bertrand Meyer's CQS) separates the write model from one or more read models. Event Sourcing stores the system of record as an append-only log of immutable domain events; current state is a fold over the log. The two pair naturally, but neither requires the other.
| Promise | Price |
|---|---|
| Perfect audit trail (every change captured) | Schema evolution of events is permanent |
| Many read models from one source of truth | Read models eventually consistent |
| Time-travel + replay for new projections | Storage grows monotonically |
| Natural fit with EDA + DDD aggregates | Significant team learning curve |
6.5 · Saga — distributed transactions without 2PC
A saga (Garcia-Molina & Salem, 1987) breaks a long-running business transaction into a sequence of local transactions, each with a compensating action that semantically undoes it on failure. Two coordination styles:
- Orchestration — a central orchestrator (Temporal, Camunda, AWS Step Functions, Netflix Conductor) tells each service what to do, in order. Easier to reason about; risks coupling.
- Choreography — services react to each other's events; no conductor. Highly decoupled; harder to trace globally.
6.6 · Strangler Fig (Fowler 2004)
Replace a legacy system gradually by deflecting traffic to new components behind a façade. Over time the legacy is "strangled" route by route until it can be retired. The pattern's strength is risk reduction: every step is reversible and shippable. Requires a routing layer (API gateway, reverse proxy, anti-corruption layer) and disciplined feature parity testing.
6.7 · Hierarchical / cellular architecture
A cell is a self-contained vertical slice of the system (services + data + dependencies) sized so that failure of any single cell is recoverable and bounded. Amazon's "Cell-Based Architecture" papers, Slack's "cells", and Shopify's "pods" are real-world examples. The cell becomes the unit of blast-radius, capacity, and routing. Cells are typically homogenous; a "cell router" (shuffle-sharded for resilience) decides which cell handles which customer. See Ch 13 for resilience implications.
Cell-based topology (blast radius isolated)
6.8 · GoF patterns refresher
The 23 patterns from Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, Helm, Johnson, Vlissides — 1994) remain the lingua franca of OO design.
| Creational | Structural | Behavioral |
|---|---|---|
| Abstract Factory · Builder · Factory Method · Prototype · Singleton | Adapter · Bridge · Composite · Decorator · Facade · Flyweight · Proxy | Chain of Responsibility · Command · Interpreter · Iterator · Mediator · Memento · Observer · State · Strategy · Template Method · Visitor |
For enterprise applications see Fowler's Patterns of Enterprise Application Architecture (2002). For cloud-native concerns see Microsoft's Cloud Design Patterns catalog (Ambassador, Anti-Corruption Layer, Bulkhead, Cache-Aside, CQRS, Circuit Breaker, Compensating Transaction, Competing Consumers, Federated Identity, Gatekeeper, Geode, Health Endpoint, Index Table, Leader Election, Materialized View, Pipes & Filters, Priority Queue, Publisher-Subscriber, Queue-Based Load Levelling, Retry, Saga, Scheduler-Agent-Supervisor, Sequential Convoy, Sharding, Sidecar, Static Content Hosting, Strangler Fig, Throttling, Valet Key). For messaging see Hohpe & Woolf's Enterprise Integration Patterns (Ch 08).
6.9 · Choosing a style
| If your top-priority NFRs are… | Consider… |
|---|---|
| Simplicity, time-to-market, single small team | Modular Monolith (Layered or Hexagonal internals) |
| Independent scaling, many teams, divergent change cadences | Microservices (with DDD bounded contexts) |
| Bursty / unpredictable load, event glue | Serverless / FaaS, EDA |
| Audit, replay, temporal queries | Event Sourcing + CQRS |
| Extreme throughput, low latency at variable load | Space-Based |
| Domain logic that outlives the tech stack | Hexagonal / Clean |
| Legacy replacement | Strangler Fig over the legacy |
| Blast-radius isolation at scale | Cellular over any underlying style |