I'm still trying to understand DDD. Let's say I have an immutable VO PresentationSlide. Because it is immutable it can be easily shared and used by different entities.
But what happens if I try to map this to a database. In EntityFramework I could model the PresentationSlide as a ComplexType, meaning the properties of the shared PresentationSlide are mapped to the tables using it. This is fine, but a Slide might be quite large and therefore I'm wasting space, if it used/reference several times.
As an alternative approach I could map a PresentationSlide to a separate table and reference it. Because it is immutable this should also work. But now, if I modify a Presentation, I have to copy the content of the old PresentationSlide and create a new instance. If there are a lot of changes, I will soon have a lot of orphaned PresentationSlides in my database.
Isn't this a problem? Is there a solution? Should I implement a custom periodical 'Cleanup orphaned PresentationSlides'-Task?
PresentationChangedor you could perform periodic cleanups. Still, sometimes it may be too expensive to use a VO although there's no real need for an identity. It feels natural to me that aPresentationSlidewould be mutable. How often do you really share aPresentationSlidebetween presentations or even re-use the same slide in a single one? - plalxPresentationSlidemeans that when a user create a newPresentationhe can choose to attach a existingPresentationSlideto thePresentationinstead of add a new one. But then you must keep orphanPresentationSlidesfor future new/modifiedPresentations. - jlvaquero