difference between association and aggregation

From the UML Superstructure 2.4.1:

An association declares that there can be links between instances of the associated types. A link is a tuple with one value for each end of the association, where each value is an instance of the type of the end. (UML Superstructure, Page 37)

Nothing more, nothing less. and very vague. Because of this, it is also very hard to understand. What I defined (In a course I teach) is a hierarchy of links from dependency to composition where:

  1. Dependency from A to B means that A uses B but indirectly (say by receiving instances of it and forwarding them to other objects).
  2. Association from A to B means that A uses B directly, (for example by calling methods)
  3. Aggregation from A to B means that B is part of A (semantically) but B can be shared and if A is deleted, B is not deleted. Note that this says nothing about how the "is part" is implemented.
  4. Composition from A to B is like Aggregation, where B cannot be shared and if A is deleted, all of its aggregates (Bs) are deleted also.

Aggregation is an Association relationship where the Association can be considered the containing class 'Owning' the contained class, and the lifetime of that relationship is not defined.

Association is an 'Has-A' relationship.

Example:-

  public class Person  
  {  
   private final Name name;  
   private Address currentAddress;  

   //...  
 } 

In this case, the Person Has-A name and Has-A Address, so there is an Association between Person and Name, and Person and Address.


An association describes a relationship between instances of one or more classes. In the words of the UML Reference Manual, "Associations are the glue that holds together a system."

Aggregation is a form of association in which there is a "whole-part" relationship. You may say that if a class Airplane has a class Engine then this forms a "whole-part" relationship.

Tags:

Oop

Uml