DDD Aggregate Root Selection

Build a time tracking application. I am trying to determine the best way to create aggregate roots.

The main main objects are Client, Project, Employee, ProjectAssignment, Department, Timesheet. The client has one or more projects, the project has one or more employees assigned to him (through ProjectAssignment), the employee belongs to the department, and the Timesheet links Project, Employee together.

The client looks like the obvious cumulative root.

Client -> Project -> ProjectAssignment -> Employee

As for the other units, I'm not sure the best way to go ...

I thought...

Department -> Employee -> Person

Or to have the Employee and the Department as separate units as a whole. Employees can only be in one department and one department. However, the department itself refers to the creation of a department hierarchy.

, ?

+4
3

DDD - , , , , . DDD , , , , DDD, .

. , , , , . , ( ) . , .

- , DDD. , , , ProjectAssignment , , Timesheet, , , -. - ( , orm), crud style. . "", , , , - , . Client Department - .

, crud. , , . -. , Client, Department Department. , . , , Client Department, , - ( ). DDD. , , , , . , , - - , crud! DDD, , , .

, DDD , . . , , , , . ddd, , .

+4

. , . , . , , (AR): Client, Project, Employee Department.

ProjectAssignment Project AR, , .

Timesheet Employee, Projects IDs , .

Employee AR Department ID, , .

0

Transactional Consistency Eventual Consistency. - .

Employee and Department. : ( ?)

, . Employee reference Department .

If this is not normal (for example, the user will not allow the employee to be deleted in the schedule incorrectly), make the Department cumulative, containing the Employee entity collection.

You can find more about this topic in the IDDD book by Vaughn Vernon: https://www.amazon.com/Implementing-Domain-Driven-Design-Vaughn-Vernon/dp/0321834577

0
source

Source: https://habr.com/ru/post/1671920/


All Articles