EntityFramework Field Driven design Practice (V): Aggregation

Source: Internet
Author: User

Aggregation (Aggregate) is a very important concept in domain-driven design. Simply put, aggregation is such a set of domain objects (both entities and value objects) that combine to represent a complete realm concept. For example, according to Eric Evans's "field-driven design" book, a car contains four wheels, the wheel leaves the "car" is meaningless, at this point the consortium is aggregation, and "car" is the aggregation root (Aggregate root).

It is learned from practice that not every entity in the domain model can fully articulate a well-defined domain concept, such as the relationship between a customer and a shipping address. Suppose that in an application, the system needs to maintain multiple shipping addresses for each customer, at which point the shipping address is an entity, not a value object. So there are at least "customer" and "shipping address" two entities in the domain model, and in fact, "shipping address" is for "customer", leaving "customer", "shipping address" becomes meaningless. So, "shipping address" and "customer" together, fully expressed the "customer can have multiple shipping address, and can maintain their" ideas.

In the field-driven practice of the Entity Framework (iii)-case: A simple sales system, we simply designed a domain model that contains the necessary entity and value objects. Now, I've circled three aggregations in this domain model with different color pens: Customers, orders, and product categories, as shown in the following illustration:

"Note": If Category-item makes up an aggregation as shown in the above illustration, then the aggregate root should be item instead of Category, because Category has no conceptually contained/included relationship to the item, and more often, Category is Item is a description of the information that an item can be categorized into a category. In this case, we do not need to maintain the category, category in the form of a value object in the domain model. If it is a different application, for example, our system needs to be promoted for category, then we need to maintain category information, whereby category and item are divided into two different aggregates, and the aggregate roots are themselves.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.