classoopinheritanceumlgrasp

Generalization With Inherited Classes


There are 2 different design. Second one is(below) improved version of first one. Difference is that I add 2 child class to B. So A is dependended to 2 child class now. but what will happen if B has more child classes later?

Is it really best practice? Especially with GRASP perspective?

two different version


Solution

  • Instad of having an association to each classes, I would prefer the following.

    enter image description here