jeudi 5 février 2015

DDD Validation: entity containing data dosen't have the context to validate before data is set


I am pretty new to DDD, so bear with me.


I have a Chat room and people in the Chat room. The people in the chat room need to propose a date they would like a webinar to be on. we have a bussiness rule, where we need to have at least 3 people in the webinar for the webinar to take place and each person interested in the webinar needs to say that they are ready for someone to propose a date


I have 2 solutions in mind


solution 1:


Making Chat room the aggregate root


Have a function propose date on the Chat room, ProposeDate(Person, Date).


In this solution I would validate the bussiness rules on the Chat room and set the date on person entity.


An issue With this solution is that we have a setter on the person entity that can be called from anywhere in the domain without the reference to the validation in the chat room, should the proposed date for each person actually be removed from the person entity and be set on the chat room itself so it cannot be set wihout calling chat room entity?


solution 2


make person the aggregate root


On Person have ProposeDate(Date).and person would ask Chat room can i propose this date. The problem i have with this solution is I believe it invalidates the tell don't ask priciple.


if i have it all wrong and there is another solution please let me know.





Aucun commentaire:

Enregistrer un commentaire