I have modelled a class structure, where subclasses
Circle inherit from an abstract superclass
Figure. All subclasses share an interface
IGeometry that provides for
getPerimeter() and needs a different implementation for each subclass. Several concrete classes hold the respective methods, e.g.
For example the class
Circle now inherits from
Figure and has a
CircleGeometry as an attribute.
What is the most reasonable way to model this relationship?
- If I model this relationship as an aggregate-relationship, where
IGeometry-object, and then the concrete aggregates for the subclasses are modelled again, i.e.
CircleGeometry, the aggregation would be in effect modelled twice in the subclasses, once inherited, once concrete (see my diagram).
- If I just model the aggregation on the superclass, but already know which subclass will hold which implementing class, I don't know how to describe their relationsship.
What if the implementing classes are
abstract, and the methods for calculating area and perimeter are