I'm facing the issue where either I can't apply DDD, or the case can't be reformulated to fit the DDD rules.
The requirements:
- We have a
Product
andLocation
. - Change in
Location
should be reflected inProduct
which user then sees. ThereforeProduct
referencesLocation
. - Same
Location
might be used in severalProducts
. Product
might be created and deleted at any time point.Location
might be created at any time point.Location
might be deleted only if there is noProduct
references thisLocation
.- Delete of a
Product
does not lead toLocation
deletion.
There are two more entities in the model exist with the same rules as Location
, but solution should be the same as with Location
case.
My thoughts:
So the problem which I see, that such requirements creates circular dependency on Product
and Location
. Because they all have own unlimited life cycle they supposed to be separate aggregation roots, but then this violates the consistency boundary, as basically one AR is trying to control another AR. So, this invariant can't be placed in any of those two. Trying to extract this into third one on the top AR also not clear how this would work.
The question:
How can I satisfy such requirements in DDD? Removing the constraint 6 is not an option. I've already tried to negotiate this with business side.
Aucun commentaire:
Enregistrer un commentaire