was the evergreen, luxury, full of fruit tree of abundance. Man adored it as if it were a divinity, until gods got gealous and so one day they put it upside-down to punish its arrogance. Since then the Baobab shows its roots.
data represent the state that the entities reach when a business operation ends • They are attributes of the entities and value objects and nothing else • If your entities only expose data, it’s not a domain model, it’s an anemic domain http://martinfowler.com/bliki/AnemicDomainModel.html 1 1
the changes of the object model • It decouples the client from the storage technology • It provides testability using collection in memory « Mediates between the domain and data mapping layers using a collection-like interface for accessing domain objects. » Martin Fowler – PoEAA
paradigms, object vs relational, we have an impedance mismatch • We can partially resolve the mismatch with an ORM (object-relational mapper) • Sacrifice some richness of object relationships to keep close to the relational model http://www.agiledata.org/essays/culturalImpedanceMismatch.html
it. So the persistence needs to know about the domain but not vice-versa • Design the persistence entities for storage purposes and to match the ORM's constraints (like making all the properties virtual). So you'll have Domain Entities and Persistence Entities, each with their own different purposes and implementations • If you correctly define each context boundary, you will obtain small entities without needing any lazy loading • If you can't simply use SQL into your repository, map a set of DTO to your database schema, and use them into factories to initialize entity classes
to domain model • I think about NoSQL databases, especially document databases: • Every aggregate is a document • Schema-free • No ORM, no mapping • Scale-out techniques, like sharding
can have a different persistence strategy in every bounded context • The technology can depend on the form of the domain model or on performance requirements • Concentrate your energy on core domains Use the right tool
• Choose a data model as close as possible with your domain model and isolate it from the persistence layer with a repository • Hide the database from other bounded contexts or external systems • If necessary, provide an API that exposes public data • Maintain also the database aligned with the ubiquitous language • Stay focused!