/patterns-of-enterprise-application-architecture

Compilation of sample code from the book Patterns of Enterprise Application Architecture by Martin Fowler.

Primary LanguageJava

Patterns of Enterprise Application Architecture

Compilation of sample code from the book Patterns of Enterprise Application Architecture by Martin Fowler.

I used and created this repo when I studied the book. Super worth reading it!

Read the book and learn more on each topic.

Enjoy! :)

Layering

  • Presentation
  • Domain Logic
  • Data Source

Patterns

Domain Logic Patterns

  • Transaction Script
  • Domain Model
  • Table Module
  • Service Layer

Data Source Patterns

  • Table Data Gateway
  • Row Data Gateway
  • Active Records
  • Data Mapper

Object-Relational Behavior Patterns

  • Unit of Work
  • Identify Map
  • Lazy Load

Object-Relational Structural Patterns

  • Identity Field
  • Foreign Key Mapping
  • Association Table Mapping
  • Dependent Mapping
  • Embedded Value
  • Serialized LOB
  • Single Table Inheritance
  • Class Table Inheritance
  • Concrete Table Inheritance
  • Inheritance Mappers

Object-Relational Metadata Mapping Patterns

  • Metadata Mapping
  • Query Object
  • Repository

Web Presentation Patterns

  • Model View Controller
  • Page Controller
  • Front Controller
  • Template View
  • Transform View
  • Two Step View
  • Application Controller

Distribution Patterns

  • Remote Facade
  • Data Transfer Object

Offline Concurrency Patterns

  • Optimistic Offline Lock
  • Pessimistic Offline Lock
  • Coarse-Grained Lock
  • Implicit Lock

Session State Patterns

  • Client Session State
  • Server Session State
  • Database Session State

Base Patterns

  • Gateway
  • Mapper
  • Layer Supertype
  • Separated Interface
  • Registry
  • Value Object
  • Money
  • Special Case
  • Plugin
  • Service Stub
  • Record Set

Details

Domain Logic Patterns

  • Transaction Script

    Organizes business logic by procedures where each procedure handles a single request from the presentation.
    Screenshot

  • Domain Model

    An object model of the domain that incorporates both behavior and data.
    Screenshot

  • Table Module

    A single instance that handles the business logic for all rows in a database table or view.
    Screenshot

  • Service Layer

    Defines an application’s boundary with a layer of services that establishes a set of available operations and coordinates the application’s response in each operation.
    Screenshot

Data Source Patterns

  • Table Data Gateway

    An object that acts as a Gateway to a database table. One instance handles all the rows in the table.
    Screenshot

  • Row Data Gateway

    An object that acts as a Gateway to a single record in a data source. There is one instance per row.
    Screenshot

  • Active Records

    An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
    Screenshot

  • Data Mapper

    A layer of Mappers (473) that moves data between objects and a database while keeping them independent of each other and the mapper itself.
    Screenshot

Object-Relational Behavior Patterns

  • Unit of Work

    Maintains a list of objects affected by a business transaction and coordinates the writing out of changes and the resolution of concurrency problems.
    Screenshot

  • Identify Map

    Ensures that each object gets loaded only once by keeping every loaded object in a map. Looks up objects using the map when referring to them.
    Screenshot

  • Lazy Load

    An object that doesn't contain all of the data you need but knows how to get it.
    Screenshot

    • Types:
      • Lazy Initialization
      • Virtual Proxy
      • Value Holder
      • Ghost

Object-Relational Structural Patterns

  • Identity Field

    Saves a database ID field in an object to maintain identity between an in-memory object and a database row.
    Screenshot

    • Types:
      • Integral
      • Key Table
      • Compound Key
  • Foreign Key Mapping

    Maps an association between objects to a foreign key reference between tables.
    Screenshot

    • Types:
      • Single-Valued Reference
      • Multi Table Find
      • Collection of References
  • Association Table Mapping

    Saves an association as a table with foreign keys to the tables that are linked by the association.
    Screenshot

  • Dependent Mapping

    Has one class perform the database mapping for a child class.
    Screenshot

  • Embedded Value

    Maps an object into several fields of another object’s table.
    Screenshot

  • Serialized LOB

    Saves a graph of objects by serializing them into a single large object (LOB), which it stores in a database field.
    Screenshot

  • Single Table Inheritance

    Represents an inheritance hierarchy of classes as a single table that has columns for all the fields of the various classes.
    Screenshot

  • Class Table Inheritance

    Represents an inheritance hierarchy of classes with one table for each class.
    Screenshot

  • Concrete Table Inheritance

    Represents an inheritance hierarchy of classes with one table per concrete class in the hierarchy.
    Screenshot

  • Inheritance Mappers

    A structure to organize database mappers that handle inheritance hierarchies.
    Screenshot

Object-Relational Metadata Mapping Patterns

  • Metadata Mapping

    Holds details of object-relational mapping in metadata.
    Screenshot

  • Query Object

    An object that represents a database query.
    Screenshot

  • Repository

    Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects.
    Screenshot

Web Presentation Patterns

  • Model View Controller

    Splits user interface interaction into three distinct roles.
    Screenshot

  • Page Controller

    An object that handles a request for a specific page or action on a Web site.
    Screenshot

  • Front Controller

    A controller that handles all requests for a Web site.
    Screenshot

  • Template View

    Renders information into HTML by embedding markers in an HTML page.
    Screenshot

  • Transform View

    A view that processes domain data element by element and transforms it into HTML.
    Screenshot

  • Two Step View

    Turns domain data into HTML in two steps: first by forming some kind of logical page, then rendering the logical page into HTML.
    Screenshot

  • Application Controller

    A centralized point for handling screen navigation and the flow of an application.
    Screenshot

Distribution Patterns

  • Remote Facade

    Provides a coarse-grained facade on fine-grained objects to improve efficiency over a network.
    Screenshot

  • Data Transfer Object

    An object that carries data between processes in order to reduce the number of method calls.
    Screenshot

Offline Concurrency Patterns

  • Optimistic Offline Lock

    Prevents conflicts between concurrent business transactions by detecting a conflict and rolling back the transaction.
    Screenshot

  • Pessimistic Offline Lock

    Prevents conflicts between concurrent business transactions by allowing only one business transaction at a time to access data.
    Screenshot

  • Coarse-Grained Lock

    Locks a set of related objects with a single lock.
    Screenshot

  • Implicit Lock

    Allows framework or layer supertype code to acquire offline locks.
    Screenshot

Session State Patterns

  • Client Session State

    Stores session state on the client.

  • Server Session State

    Keeps the session state on a server system in a serialized form.

  • Database Session State

    Stores session data as committed data in the database.

Base Patterns

  • Gateway

    An object that encapsulates access to an external system or resource.
    Screenshot

  • Mapper

    An object that sets up a communication between two independent objects.
    Screenshot

  • Layer Supertype

    A type that acts as the supertype for all types in its layer.

  • Separated Interface

    Defines an interface in a separate package from its implementation.
    Screenshot

  • Registry

    A well-known object that other objects can use to find common objects and services.
    Screenshot

  • Value Object

    A small simple object, like money or a date range, whose equality isn’t based on identity.

  • Money

    Represents a monetary value.
    Screenshot

  • Special Case

    A subclass that provides special behavior for particular cases.
    Screenshot

  • Plugin

    Links classes during configuration rather than compilation.
    Screenshot

  • Service Stub

    Removes dependence upon problematic services during testing.
    Screenshot

  • Record Set

    An in-memory representation of tabular data.
    Screenshot