views:

232

answers:

2

Hi, I would like to ask for a reccomended solution for this: We have a list of Competitions. Each competition has defined fee that a participatior has to pay We have Participators I have to know has a Participator that is on a Competition paid the fee or not. I am thinking about 2 solutions and the thing is it has to be the most appropriate solution in Domain Driven Design. First is to create a Dictionary in Competition instead of a List, the dictionary would have be of type <Participator, bool>. The secont is perhaps create a different class that has 2 fields, a participator and feePaid. And in Competiton I would have a list of object of that new class.

Thank you

+3  A: 

The way I would handle this is to have Competitions, Participants, and Registrations. A Participant would register for a Competition, creating a Registration. A Registration would consist of the Competition id, Participant id, a flag indicating whether the fee was paid or not, and any other registration-specific data (like the date of registration). This would be modeled in the database as a "join table" (with the additional data). On the app side, a Participant would have a list of Registrations, each Registration would have an associated Participant and a Competition. Likewise, each Competition would have a list of Registrations.

tvanfosson
I am not sure is it the correct way to do it in Domain Driven Development. As in DDD you can handle objects and it wouldn't be good to have an object that has IDs only and one more information. I know this would be a standard solution in databases.
gljivar
I disagree, my model typically has an ID for any object I need to persist in a database because I need some way to map things after the usual IRepository work - DDD has more to do with trying to speak a unified language w/ the business than trying to exclude an ID property IMHO
Toran Billups
+6  A: 

sounds like a typical many to many relationship. i would model it with an Entry association class as follows:

class Participator {
}
class Competition {
    Currency fee
}
class Entry {
    Competition competition
    Participator participator
    Boolean feePaid
}
Ray Tayek