Skip to content

Instantly share code, notes, and snippets.

@cystbear
Created December 16, 2013 23:31
Show Gist options
  • Save cystbear/7996888 to your computer and use it in GitHub Desktop.
Save cystbear/7996888 to your computer and use it in GitHub Desktop.

Domain Model

How It Works

Putting a Domain Model in an application involves inserting a whole layer of objects that model the business area you're working in. You'll find objects that mimic the data in the business and objects that capture the rules the business uses. Mostly the data and process are combined to cluster the processes close to the data they work with.

An OO domain model will often look similar to a database model, yet it will still have a lot of differences. A Domain Model mingles data and process, has multivalued attributes and a complex web of associations, and uses inheritance.

As a result I see two styles of Domain Model in the field. A simple Domain Model looks very much like the database design with mostly one domain object for each database table. A rich Domain Model can look different from the database design, with inheritance, strategies, and other [Gang of Four] patterns, and complex webs of small interconnected objects. A rich Domain Model is better for more complex logic, but is harder to map to the database. A simple Domain Model can use Active Record (160), whereas a rich Domain Model requires Data Mapper (165).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment