Skip to content

Instantly share code, notes, and snippets.

@janx
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janx/d8dc98870373d06c9e8d to your computer and use it in GitHub Desktop.
Save janx/d8dc98870373d06c9e8d to your computer and use it in GitHub Desktop.
Description of ActiveRecord pattern from <Patterns of Enterprise Application Architecture>
In simple applications the Domain Model (116) is an uncomplicated structure that actually corresponds pretty
closely to the database structure, with one domain class per database table. Such domain objects often have
only moderately complex business logic. In this case it makes sense to have each domain object be
responsible for loading and saving from the database, which is Active Record (160) (see Figure 3.3). Another
way to think of the Active Record (160) is that you start with a Row Data Gateway (152) and then add domain
logic to the class, particularly when you see repetitive code in multiple Transaction Scripts (110).
...
As the domain logic gets more complicated and you begin moving toward a rich Domain Model (116), the simple
approach of an Active Record (160) starts to break down.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment