ufmatic.blogg.se

Domain driven design model
Domain driven design model








domain driven design model

For retrieving a single instance of an order entity this approach is acceptable however for collections of orders, as in the case of the GetMostRecent method on the order repository, this results in the select N+1 problem. This can be achieved using several fetching strategies, including joining the order line items table or issuing a second select statement to the database. When retrieving an order entity, the repository must also retrieve the order line items in order for the entity to be complete. The relationship between an order and an order line item is one-to-many and in a relational model there would be a table for the orders and a table for the order line items related by a foreign key. However if implemented using an ORM such as NHibernate certain caveats arise even in this simplistic scenario. In C# the corresponding classes might look something like this:įrom a client perspective the repository contract satisfies the requirements. The order total is a sum of the constituent line item totals and the tax and shipping charges. The requirement for this type of summarizing information depends on the project, but is commonplace in applications involving any type of GUI.Ĭonsider the standard order model with an order entity containing a collection of line items.

domain driven design model

The basic premise of this approach is to leverage the underlying database, a relational database in particular, for what it’s good at - namely aggregation, filtering, and projection. This particular responsibility is not well explored or developed and as a result is often overlooked in practice. Eric Evans attributes another potential responsibility to a repository in the blue book:Īlthough most queries return an object or a collection of objects, it also fits within the concept to return some types of summary calculations, such as an object count, or a sum of a numerical attribute that was intended by the model to be tallied. Repositories are typically used to provide access to aggregate roots, entities and less frequently to value objects. Domain-Driven Design espouses the repository pattern as a way to persist and reconstitute domain objects from a persistent store such as a database.










Domain driven design model