Domain Driven Design Entity Vs Aggregate
By keeping state objects separate from the domain driven implementation objects it enables very simple mappings.
Domain driven design entity vs aggregate. Ensure decent database performance. We let entity. But that may be because i haven t seen a domain yet where the model needed anything more complicated. Obviously a fund is an entity aggregate root even.
The idea is that a given aggregate root has a method that corresponds to a command and a command handler invokes the method on the aggregate root. Let s add another goal to our aggregate design list. Feb 15 2019 4 min read. A ddd aggregate is a cluster of domain objects that can be treated as a single unit.
Things like trades and positions are most likely value objects. I m working in the financial domain at the moment. Quite often we need to map a domain entity to a dto view model to return to the user. An example may be an order and its line items these will be separate objects but it s useful to treat the order together with its line items as a single aggregate.
Those funds often invest into other funds. The aggregate root is responsible for performing the logic of the operation and yielding either a number of events or a failure exception or execution result enumeration number response or. I ve typically only had each entity be part of one aggregate. This results in a tree structure of sorts with one fund at the top anchoring it all together.
Aggregate is a pattern in domain driven design. My motivation for this blog is to share some understanding on aggregates what they are and why they are. Provide enough info to enforce model invariants within a boundary. 18 19 and 24.
There s also the case of dtos. As shown in figure 6 the domain object defines and implements the domain driven model using the ubiquitous language and the state objects hold the state of the aggregate. We have funds hedge variety. For background reading see the ddd reference book especially pp.
Aggregate boundaries and behavior. Aggregates in domain driven design. The second approach uses a domain object backed by state objects.