I become a big fan of DDD . So, I am thinking about applying it correctly to my current system, which I am developing.
Suppose we have two aggregate roots: Order and User . Order has two properties, referring to User : owner and contractor . The owner created the Order , the contractor completed it.
Owners can appreciate the quality with which Order performed by the contractor. So, we have a Feedback object associated with Order containing a rating.
Now the User object contains the average rating of each user through the completed orders. And this part bothers me a little.
User rating is not just a static property, but actually the average value of all ratings in Feedbacks . And it changes (should be recounted) at the time of joining Order Feedback .
Currently, I have some services encapsulating the domain logic: OrderService and UserService (I know that this actually does not correspond to DDD, but I will reorganize it later). When the OrderService receives a command to attach feedback to the order, it issues an OrderFeedbackAttachedEvent , which the UserService listens to recalculate the user rating.
What does not satisfy me is that now the information about the root unit of the order has now been leaked to UserService. And I see no way to avoid this. I'm starting to think that for such cases there must be some kind of model.
Rating
Rating seems to be an ideal property of the user. But the fact that this is not a static, constant value, but rather something that is calculated based on data from other objects, causes me doubts.
Rating is also not an entity. This is not an object of value. What is interesting in DDD? And how do I model estimates (or any other calculated values) in my system without sacrificing performance and ease of use)?