admin管理员组文章数量:1418062
I have an aggregate root named Building.
In the Building class, I have three methods for adding, updating, and deleting a building.
- When adding a building, I create a new Building object.
- When updating, I create a new version of the Building.
- When deleting, I check if the entity has no related dependencies before allowing deletion. I also have a BuildingService that handles these operations.
Inside Building, I have an entity named Floor, which is also an entity root. The Building class contains a list of floors, and I have three methods for adding, updating, and deleting floors within this list. Additionally, I have a FloorService that manages the Floor entity.
Now, I want to add an entity under Floor called Unit. Unit should be structured similarly to Floor—it will be an entity root. However, I am confused about how to implement the add, update, and delete methods for Unit.
Building manages Floor, even though Floor is an entity root. Unit should be managed by Floor, but since Floor is already an entity root, how can I allow Floor to manage Unit while maintaining DDD best practices? I want to handle the Unit entity similarly to how Floor is handled within Building, but I am unsure how to structure this correctly.
What is the best approach to managing Unit under Floor while ensuring consistency and adhering to DDD principles?
本文标签:
版权声明:本文标题:domain driven design - How to Handle Add, Update, and Delete Operations for an Entity Under an Entity Root in DDD? - Stack Overf 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739221686a2150618.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论