What Belongs to the Aggregate Root

前端 未结 7 1396
温柔的废话
温柔的废话 2021-01-30 05:43

This is a practical Domain Driven Design question:

Conceptually, I think I get Aggregate roots until I go to define one.

I have an Employee entity, which has sur

7条回答
  •  后悔当初
    2021-01-30 06:10

    You say that you have employee entity and violations and each violation does not have any behavior itself. From what I can read above, it seems to me that you may have two aggregate roots:

    • Employee
    • EmployeeViolations (call it EmployeeViolationCard or EmployeeViolationRecords)

    EmployeeViolations is identified by the same employee ID and it holds a collection of violation objects. You get behavior for employee and violations separated this way and you don't get Violation entity without behavior.

    Whether violation is entity or value object you should decide based on its properties.

提交回复
热议问题