mercredi 24 juin 2015

Avoiding redundancy in Composition pattern java

I have two classes A and B. Now, I have B "has a" A relationship. So, the most trivial thing to follow here is the Composition pattern. Now, one of the field of B is an object of A. The problem is some of the fields of A and B are common. So, in this case, those fields will be redundant. I can't create an abstract class out of the common fields and make A and B inherit it because they are already extending some abstract class. What would be the best practice in this case?

Aucun commentaire:

Enregistrer un commentaire