Search code examples
umlassociationsaggregationclass-diagram

UML aggregation vs association


From Martin Fowler's UML Distilled:

In the pre-UML days, people were usually rather vague on what was aggregation and what was association. Whether vague or not, they were always inconsistent with everyone else. As a result, many modelers think that aggregation is important, although for different reasons. So the UML included aggregation (Figure 5.3) but with hardly any semantics. As Jim Rumbaugh says, "Think of it as a modeling placebo" [Rumbaugh, UML Reference].

What I understand from this and answers I read on Stack Overflow is that it doesn't matter which one of these two relations I use, they're basically the same thing. Is this the case or are there some situations where the use of aggregation instead of association (and vice-versa) could be justified?


Solution

  • Rumbaugh's statement is the most telling and Uncle Bob's good advice. As I've said elsewhere, Aggregation is semantically so weak as to offer nothing practically beneficial. It only has one valid corner case (acyclicity of recursive relationships) however few people know and understand that. So you end up having to point out in comments anyway.

    I just don't use it. And have never felt any loss. Stick with simple binary associations and focus on what really matters - getting the cardinality and naming right. You'll get far more from that than trying to decide the undecidable association vs. aggregation.

    hth.