Information Technology Reference
In-Depth Information
Fig. 3.5 Association
between classes
Consults
Class
Class
3.3 Associations
Computer programming has long been considered a related field to that of lin-
guistics. After all, programming languages are simply a combination of grammar
and vocabulary created for a specific purpose. In a related sense, we can think of
classes as nouns in our modeling language. They represent things; entities that
exist within the system. In order to form proper and complete sentences, though,
we need verbs to describe what it is that our nouns do. In this case, our verbs are
associations. Associations express the relationships between classes, and thus
describe the actions that define their interactions. In the same way that objects are
instances of classes, associations too have instances, called links in UML. Asso-
ciations describe the relationships between classes. Links describe the relation-
ships between objects. As we described in the previous section, associations are
depicted by a line connecting two classes. In Fig. 3.5 , an association called
Consults defines the relationship between classes A and B .
3.3.1 Aggregation
Aggregation is a relationship in which one class completely contains another
class. Real world examples could include a hotel class that contains a
hotel_room or a soccer_team class which contains a soccer_player .
The UML diagram below denotes aggregation between a Country class and a
State class.
Figure 3.6 the Country is the owner class. The diamond ended line connecting
the two classes denotes the aggregation relationship, with the diamond end always
pointing to the owner class. The State class in this example is called the owned,
part, or component class. In most cases, the owner is responsible for construction
and destruction of the owned class.
Fig. 3.6 Example of
aggregation
Country
State
Search WWH ::




Custom Search