Patterns
Patterns of Enterprise Application Architecture
Fowler's POSAA catalog, organised by chapter.
Patterns of Enterprise Application Architecture is Martin Fowler’s catalog of the recurring structures in enterprise software: layering, domain logic, object-relational mapping, concurrency, session state, distribution, and the base patterns they build on. The catalog below is organised by Fowler’s chapter categories.
Domain Logic Patterns
How business rules are organised in code — from Transaction Script’s one-procedure-per-action to Domain Model’s object graph, with Table Module and Service Layer as the intermediate and boundary forms.
Data Source Architectural Patterns
How application code talks to a database: Table Data Gateway and Row Data Gateway expose the schema, Active Record binds a row to a domain object, and Data Mapper keeps domain and schema independent through a separate mapping layer.
Object-Relational Behavioral Patterns
The behavioural machinery of mapping: Unit of Work tracks what changed in a transaction, Identity Map keeps one in-memory copy per row, and Lazy Load defers fetching associated data until it is needed.
Object-Relational Structural Patterns
How objects and relational structure line up: Identity Field, Foreign Key Mapping, Association Table Mapping, and Dependent Mapping for relationships, plus Embedded Value, Serialized LOB, and the three inheritance-mapping strategies for the awkward parts.
Object-Relational Metadata Mapping Patterns
Putting the mapping itself in metadata rather than hand-written code: Metadata Mapping drives the mapping from a description, Query Object builds queries as objects, and Repository mediates between domain and data layers with a collection-like interface.
Web Presentation Patterns
Separating HTTP handling from presentation and domain logic: Model View Controller, Page Controller and Front Controller for request routing, Template View and Transform View for rendering, and Application Controller for dispatching.
Distribution Patterns
Making remote calls affordable: Remote Facade wraps fine-grained objects in a coarse-grained interface, and Data Transfer Object carries data across the boundary in a single round trip.
Offline Concurrency Patterns
Concurrency when a business transaction spans more than one system transaction, so several users can hold a copy of the same record before anyone saves. Fowler’s four patterns cover the two ends of the tradeoff, plus how the lock is acquired and how far it reaches:
Base Patterns
The small, widely reused building blocks the rest of the catalog leans on: Gateway, Mapper, Layer Supertype, Separated Interface, Registry, Value Object, Money, Special Case, Plugin, Service Stub, and Record Set.
In this notebook
- Coarse-Grained LockLock the parent once; every child inside it is implicitly protected by the same acquisition.
- Implicit LockLet the repository or framework take the lock so application code never has to remember the lock API.
- Optimistic Offline LockLet transactions proceed in parallel; detect conflicts at commit via a version stamp and retry.
- Pessimistic Offline LockLock the data up front so concurrent transactions can't interleave their work on the same aggregate.