lundi 3 août 2015

Design approch for embedding common properties only belongs to some model classes

I have below class heirachchy.

B extends A C extends A D extends A

Now suppose I have some properties which reside in both B and C and not in D. Also model classes can keep on adding. So initially those properties reside in parenrent class but then it will be inherited for sub classes which they not belong to. Then again since I go with mongo db with one collection I believe there is no harm of keep them in parent class but it will not be a good model design. So what would be the design approach for achieve this? I have like composition in my mind but bit confused on how to implement it.

Aucun commentaire:

Enregistrer un commentaire