I'm trying to apply DDD and I have some doubts. I'm reading Scott Millet DDD book and I've just read Aggregates chapters.
Imagine a simple domain model like this:
class Candidate
val id: CandidateId
val name:Name
val musicStylesPreferences: List<MusicStyle>
val sportPreferences: List<Sport>
val smoking: Boolean
enum MusicStylePreference
ROCK, METAL, POP, HIPHOP
The other objects are like this.
If we think about persisting the Candidate
, my approach is like this:
*DatabaseObject*
CandidateVO
val id: String
val name: String
MusicStylePreferenceVO
val candidateId: String
val StyleName: String
When I persist the Candidate
object in database I will persist in the appropriate table and when I hydrate the aggregate, I will query the tables.
I'm not sure if this approach is correct, I'm also thinking that maybe the objects like MusicStylePreference
, Smoking
etc ... doesn't need to be consistent and transactional (some of the advantages of aggregates) and can be outside of the aggregate Candidate
.
What do you think?
I appreciate any answer. Thanks :)