The model is not
source code.
You have code that reflects the model,
and it contains words that come from the
model.
But code is just an implementation of
the model. The model exists in the mind
of the developer.
The model is not
the database.
Some of the data associated with the
model is in the database. And the
database schema is another
implementation of the model.
But the model encompasses all of the
domain logic AND data, and it exists in
the mind of the developer.
The model is not a
diagram
A diagram is just a picture of the model.
The model itself exists in the mind of
the developer.
Entities
Objects with a unique, persistent identity
We track this identity using a key or a combination of
properties
Some examples of entities:
Entity Type Identifier
• Person/User Email
• Bank Account Account #
• Shipping Route Id
• Book ISBN
Value Objects
Second class objects with no identity, just value
Value objects are always properties of entities
They’re immutable: they’re usually only changed by
replacement
CitationService.formatBook(string title, CiteStyle style)
1. Call the WorldCat API to get publication info about the book.
2. Pass the WorldCat response object to BookFactory.fromWorldCat()
3. For analytics, pass the Book object to BookRepository and call
BookRepository.save().
4. Using the name of the CiteStyle, pass the Book to a ViewFactory
for formatting and return the View.
Some Benefits of Repositories
• A repository is an interface, so you can read and write persistent
data without knowing where it’s going. You can say repository.read()
and it might read from a REST API, web sockets, local storage, or
even memory.
• That’s why a repository is called a Persistence Abstraction Layer.
References
Objects in one layer can refer to objects in any lower layer.
Objects in one layer can refer to objects in that same layer.
Objects in one layer CANNOT REFER TO OBJECTS IN A HIGHER LAYER.
Let’s Get Some Practice
For some more good reading, go to http://www.loewenbraeuzelt.de/wp-content/
uploads/DomainDrivenDesignQuicklyOnline.pdf
Or check out Eric Evans’ Book, Domain Driven Design
In This Presentation
• See the working app: cornellnotes.nodejitsu.com
• GraphJS: https://github.com/cameronprattedwards/graphjs
• entity-context: https://github.com/cameronprattedwards/entity-context
Contributors wanted!