mardi 23 août 2016

Object Composition - Should a Constituent Know the Composing Object?

I'm building an application that has reports, and each report contains several result. This is definetely a HAS-A composition type relationship between report and result.

My question is this: should a result know to which report it belongs?

Method A (where a result doesn't know which report it belongs to):
Report:
    name
    id
    results[]


Result:
    value
    type
    id


Method B (where a result knows which report it belongs to, but the report doesn't contain the results):

Report:
    name
    id

Result:
    value
    type
    id
    report_id

Aucun commentaire:

Enregistrer un commentaire