views:

55

answers:

4

Hi, I have the following relationship:


Route * ------ * RouteLeg


I'd like to make this an Aggregation since a Route is composed by multiple RouteLegs.

However, if I delete a Route, its RouteLegs do not necessarily get deleted too (although, most of the time, they will), since they may be used in other Routes.

Is it appropriate to show this relationship as an Aggregation?

Like this:


Route * <>---- * RouteLeg


I have this doubt due to the fact that Jim Arlow in its "UML 2 and the Unified Process: Practical Object-Oriented Analysis and Design" book, doesn't see a many-to-many relationship as an aggregation, But it makes sense to me...

Anyone has evidence that it is possible to have many-to-many aggregations? Thanks very much in advance.

A: 

This is an association, because aggregation really doesn't make sense for a many to many relationship. In an aggregation, usually one side has zero or more of the other, while the other side belongs to exactly one aggregate. You have a many to many relationship where neither side really controls the other, other than the fact that a RouteLeg probably belongs to at least one route. However, because of the fact that a RouteLeg could potentially be shared by multiple routes, it may not belong to nor may it be controlled by any single route. I would say you should stick with an association, because it is the correct "connection" between the two types specified.

Michael Goldshteyn
A: 

As Arlow said, many-to-many does not fit very well into an aggregation. Aggregation represents a part-whole relationship. It is verbalized by a "has a" verb. Thus, modeling a many-to-many relationship as an aggregation introduces a faulty design.

The solution depends your design decisions. I think that a Route-RouteLeg relationship is more of a one-to-many relationship. A route "has" one (or more) RouteLegs, but a RouteLeg does not seem to fit into more than one route, I mean design wise not programing wise.

[Route](1)<>---- (1..*)[RouteLeg]

Otherwise, you may choose to decouple it to just an association

[Route](0..*)----(1..*)[RouteLeg]

Mustafa