10

does one usually put aggregating associations between interfaces?

Example:

Example Diagram

Here, I feel that one aggregation is redundant. The one between the interfaces is more important, because that's what the clients of the classes will be using. BMW and LuxuryWheel will always be used through ICar and IWheel. However, ICar does not really aggregate IWheel, as it is an interface and contains no actual logic. BMW does clearly aggregate LuxuryWheel but that is almost an implementation detail.

How would you model this? Is there a way in UML to mark an aggregation (or association) as abstract, or to-be-implemented?

TheFogger
  • 2,399
  • 1
  • 20
  • 22

1 Answers1

10

If you look at the UML spec, you'll find that in 7.3.24:

In particular, an association between interfaces implies that a conforming association must exist between implementations of the interfaces.

So, yes, you can draw aggregations between interfaces, but your diagram may not exactly mean what you expect.

Volker Stolz
  • 7,274
  • 1
  • 32
  • 50
  • 1
    7.3.24 seems relevant. If I read that section (and look at the example) it seems to me that one does not explicitly model the association between the concrete classes. They are implied through the association between the interfaces. That means that the association between BMW and LuxuryWheel is superflous. – TheFogger Mar 14 '11 at 12:41
  • 1
    @TheFogger: well, that's the question...if the "must exist" in the spec means that it SHOULD be in the model, then BECAUSE you have the association between the interfaces, you MUST have the association between the instance of ICar (BMW) and IWheel (LuxuryWheel). On the other hand, sometimes I'm not very confident with the natural language descriptions of the UML spec, and I'd say you have ventured into one of those gray areas. Maybe you should use an abstract class ACar which has an aggregation of AWheels instead of interfaces. That's what most people would be comfortable with. – Volker Stolz Mar 14 '11 at 12:48