Associations (OOM)

An association represents a structural relationship between classes or between a class and an interface.

An association can be created in the following diagrams:


It is drawn as a solid line between the pair of objects.



In addition to naming the association itself, you can specify a role name for each end in order to describe the function of a class as viewed by the opposite class. For example, a person considers the company where he works as an employer, and the company considers this person as an employee.



Reflexive Association

A reflexive association is an association between a class and itself.

In the following example, the association Supervise expresses the fact that an employee can, at the same time, be a manager and someone to manage.



In the Dependencies tab of the class, you can see two identical occurrences of the association, this is to indicate that the association is reflexive and serves as origin and destination for the link.

Aggregation

An aggregation is a special type of association in which one class represents a larger thing (a whole) made of smaller things (the parts). This is sometimes known as a "has-a" link, and allows you to represent the fact that an object of the whole has objects of the part. In the following example, the family is the whole that can contain children.



You can create an aggregation directly using the Aggregation tool in the Palette. The aggregation symbol in a diagram is the following:



Composition

A composition is a special type of aggregation in which the parts are strongly tied to the whole. In a composition, an object may be a part of only one composite at a time, and the composite object manages the creation and destruction of its parts. In the following example, the frame is a part of a window. If you destroy the window object, the frame part also disappears.



You can create a composition directly using the Composition tool in the Palette. The composition symbol in a diagram is the following:



You can define one of the roles of an association as being either an aggregation or a composition. The Container property needs to be defined to specify which of the two roles is an aggregation or a composition.


Created October 7, 2009. Send feedback on this help topic to Sybase Technical Publications: pubs@sybase.com