Let's say an
Entity is composed of multiple
ValueObjects. For instance, a wanderer might leave a few footprints behind.
Imagine I load
Wanderer from a repository and delete all footsteps north of the Canadian border. Since
Footstep is a value object without identity (ID), how would the repository know which ones need to be deleted in the database? Is it supposed to delete all and write back only the ones held by the domain object it was given?
Similarly, consider a
Milestones holding several
Issues that can either be opened or closed. I should be able to modify any
Issue's state independent of whether it is grouped by a
Milestone or not.
However, if I do close an
Issue, the progress towards the
Milestone (defined as the ratio of closed to total
Issues contained) changes, and so does the representation of the
Milestone which I'd like to update to reflect the new progress. Do Domain Events come into play here?
How are you supposed to handle such cases in the context of DDD?