I have the following 3 domain objects: Competition, Season, and Match
Competition has many Seasons
Season has many competitions
Competition is the aggregate root for Season because a Season cannot exist without a Competition
Examples:
Competition:
Premiership -> Season 1, Season 2
FA Cup -> Season 1, Season 2
League Cup -> Season 1, Season 2
Season:
Season 1 -> Premiership, FA Cup, League Cup
Season 2 -> Premiership, FA Cup, League Cup
Competition also has many Matches
Season also has many Matches
competition->getMatches() returns all matches for every season
season->getMatches() returns all matches for every competition
Question. In the context of DDD what is the best way to get all matches for a combination of competition and season? For example, matches just from Premiership Season 1?
As far as I am aware there are 3 approaches:
- Pass in
SeasonintoPremiership->getMatches(Season)with a loop findCompetitionwith thatSeason, then with another loop findMatchesbelonging to both the selectedCompetitionand the passed inSeason. The same principle can be applied vice versaSeason 1->getMatches(Competition). But what about perfomrance? - Implement the Temporal Pattern.
- Just create in repository/dao/whatever a method to
findMatchesByCompetitionAndSeason(Competition, Season)but doesn't this defeat the purpose of DDD?
Thanks for your time
Aucun commentaire:
Enregistrer un commentaire