Thursday, June 25, 2009

Associations in UML

In UML, an association represents a relationship between classes. The representation varies depending on the specifics.

Association
Represents a simple relationship between classes.

Representation: Solid line (bi-direcitonal); Solid line with arrow (unidirectional).
Implementation: Via member variables.

Aggregation
Also known as weak aggregation. Represents a whole-part relationship.

Representation: Solid line with open diamond (bi-directional); Solid line with open diamond on one end and arrow on the other (unidirectional). Open diamond's side is the whole.
Implementation: Via member variables.

Composition
Also known as strong aggregation. Represents a whole-part relationship where the part's existence is dependent on the whole.

Representation: Solid line with solid diamond (bi-directional); Solid line with solid diamond and arrow (unidirectional). Solid diamond's side is the whole.
Implementation: Via member variable.

Weak Association
Representation: Dash line (bi-directional); Dash line with arrow (unidirectional).
Implementation: Via method arguments.

No comments:

Post a Comment