Terms and Concepts
A relationship is a connection among things. In object-oriented modeling, the four most important relationships are dependencies, generalizations, associations, and realizations. Graphically, a relationship is rendered as a path, with different kinds of lines used to distinguish the different relationships.
Dependencies
A dependency is a using relationship, specifying that a change in the specification of one thing (for example, class SetTopController) may affect another thing that uses it (for example, class ChannelIterator), but not the reverse. Graphically, a dependency is rendered as a dashed line, directed to the thing that is depended on. Apply dependencies when you want to show one thing using another.
The basic properties of dependencies are discussed in Chapter 5 . |
The UML's extensibility mechanisms are discussed in Chapter 6 . |
Class diagrams are discussed in Chapter 8 . |
1. bind | Specifies that the source instantiates the target template using the given actual parameters |
Templates and bind dependencies are discussed in Chapter 9 . |
2. derive | Specifies that the source may be computed from the target |
Attributes are discussed in Chapters 4 and 9; associations are discussed in Chapter 5 and later in this chapter. |
3. permit | Specifies that the source is given special visibility into the target |
Permit dependencies are discussed in Chapter 5 . |
The class/object dichotomy is discussed in Chapter 2 . |
6. powertype | Specifies that the target is a powertype of the source; a powertype is a classifier whose objects are the children of a given parent |
Modeling logical databases is discussed in Chapter 8; modeling physical databases is discussed in Chapter 30 . |
7. refine | Specifies that the source is at a finer degree of abstraction than the target |
8. use | Specifies that the semantics of the source element depends on the semantics of the public part of the target |
Packages are discussed in Chapter 12 . |
Use cases are discussed in Chapter 17 . |
Interactions are discussed in Chapter 16 . |
Specifies that the source class sends the target event |
State machines are discussed in Chapter 22 . |
Systems and models are discussed in Chapter 32 . |
Specifies that the target is a historical predecessor of the source from an earlier stage of development |
The five views of an architecture are discussed in Chapter 2 . |
Generalizations
A generalization is a relationship between a general classifier (called the superclass or parent) and a more specific classifier (called the subclass or child). For example, you might encounter the general class Window with its more specific subclass, MultiPaneWindow. With a generalization relationship from the child to the parent, the child (MultiPaneWindow) will inherit all the structure and behavior of the parent (Window). The child may even add new structure and behavior, or it may override the behavior of the parent. In a generalization relationship, instances of the child may be used anywhere instances of the parent applymeaning that the child is substitutable for the parent.
The basic properties of generalizations are discussed in Chapter 5 . |
Figure 10-2. Multiple Inheritance

The UML's extensibility mechanisms are discussed in Chapter 6 . |
The general properties of diagrams are discussed in Chapter 7 . |
Types and interfaces are discussed in Chapter 11; interactions are discussed in Chapter 16 . |
Associations
An association is a structural relationship, specifying that objects of one thing are connected to objects of another. For example, a Library class might have a one-to-many association to a Book class, indicating that each Book instance is owned by one Library instance. Furthermore, given a Book, you can find its owning Library, and given a Library, you can navigate to all its Books. Graphically, an association is rendered as a solid line connecting the same or different classes. You use associations when you want to show structural relationships.
The basic properties of associations are discussed in Chapter 5 . |
Navigation
Given a plain, unadorned association between two classes, such as Book and Library, it's possible to navigate from objects of one kind to objects of the other kind. Unless otherwise specified, navigation across an association is bidirectional. However, there are some circumstances in which you'll want to limit navigation to just one direction. For example, as Figure 10-3 shows, when modeling the services of an operating system, you'll find an association between User and Password objects. Given a User, you'll want to be able to find the corresponding Password objects; but given a Password, you don't want to be able to identify the corresponding User. You can explicitly represent the direction of navigation by adorning an association with an arrowhead pointing to the direction of traversal.
Figure 10-3. Navigation

Visibility
Given an association between two classes, objects of one class can see and navigate to objects of the other unless otherwise restricted by an explicit statement of navigation. However, there are circumstances in which you'll want to limit the visibility across that association relative to objects outside the association. For example, as Figure 10-4 shows, there is an association between UserGroup and User and another between User and Password. Given a User object, it's possible to identify its corresponding Password objects. However, a Password is private to a User, so it shouldn't be accessible from the outside (unless, of course, the User explicitly exposes access to the Password, perhaps through some public operation). Therefore, as the figure shows, given a UserGroup object, you can navigate to its User objects (and vice versa), but you cannot in turn see the User object's Password objects; they are private to the User. In the UML, you can specify three levels of visibility for an association end, just as you can for a class's features by appending a visibility symbol to a role name. Unless otherwise noted, the visibility of a role is public. Private visibility indicates that objects at that end are not accessible to any objects outside the association; protected visibility indicates that objects at that end are not accessible to any objects outside the association, except for children of the other end. Package visibility indicates that classes declared in the same package can see the given element; this does not apply to association ends.
Figure 10-4. Visibility

Public, protected, private, and package visibility are discussed in Chapter 9 . |
Qualification
In the context of an association, one of the most common modeling idioms you'll encounter is the problem of lookup. Given an object at one end of an association, how do you identify an object or set of objects at the other end? For example, consider the problem of modeling a work desk at a manufacturing site at which returned items are processed to be fixed. As Figure 10-5 shows, you'd model an association between two classes, WorkDesk and ReturnedItem. In the context of the WorkDesk, you'd have a jobId that would identify a particular ReturnedItem. In that sense, jobId is an attribute of the association. It's not a feature of ReturnedItem because items really have no knowledge of things like repairs or jobs. Then, given an object of WorkDesk and given a particular value for jobId, you can navigate to zero or one objects of ReturnedItem. In the UML, you'd model this idiom using a qualifier, which is an association attribute whose values identify a subset of objects (usually a single object) related to an object across an association. You render a qualifier as a small rectangle attached to the end of an association, placing the attributes in the rectangle, as the figure shows. The source object, together with the values of the qualifier's attributes, yield a target object (if the target multiplicity is at most one) or a set of objects (if the target multiplicity is many).
Figure 10-5. Qualification

Attributes are discussed in Chapters 4 and 9 . |
Composition
Aggregation turns out to be a simple concept with some fairly deep semantics. Simple aggregation is entirely conceptual and does nothing more than distinguish a "whole" from a "part." Simple aggregation does not change the meaning of navigation across the association between the whole and its parts, nor does it link the lifetimes of the whole and its parts.
Simple aggregation is discussed in Chapter 5 . |
An attribute is essentially a shorthand for composition; attributes are discussed in Chapters 4 and 9 . |
Figure 10-6. Composition

Internal structure is discussed in Chapter 15 . |
Association Classes
In an association between two classes, the association itself might have properties. For example, in an employer/employee relationship between a Company and a Person, there is a Job that represents the properties of that relationship that apply to exactly one pairing of the Person and Company. It wouldn't be appropriate to model this situation with a Company to Job association together with a Job to Person association.
Attributes are discussed in Chapters 4 and 9 . |
Figure 10-7. Association Classes

Constraints
These simple and advanced properties of associations are sufficient for most of the structural relationships you'll encounter. However, if you want to specify a shade of meaning, the UML defines five constraints that may be applied to association relationships.
The UML's extensibility mechanisms are discussed in Chapter 6 . |
1. ordered | Specifies that the set of objects at one end of an association are in an explicit order. |
These changeability properties apply to attributes as well, as discussed in Chapter 9; links are discussed in Chapter 16 . |
2. set | The objects are unique with no duplicates. |
3. bag | The objects are nonunique, may be duplicates. |
4. ordered set | The objects are unique but ordered. |
5. list or sequence | The objects are ordered, may be duplicates. |
6. readonly | A link, once added from an object on the opposite end of the association, may not be modified or deleted. The default in the absence of this constraint is unlimited changeability. |
Realizations
A realization is a semantic relationship between classifiers in which one classifier specifies a contract that another classifier guarantees to carry out. Graphically, a realization is rendered as a dashed directed line with a large open arrowhead pointing to the classifier that specifies the contract.Realization is different enough from dependency, generalization, and association relationships that it is treated as a separate kind of relationship. Semantically, realization is somewhat of a cross between dependency and generalization, and its notation is a combination of the notation for dependency and generalization. You'll use realization in two circumstances: in the context of interfaces and in the context of collaborations.
Interfaces are discussed in Chapter 11; classes are discussed in Chapters 4 and components are discussed in Chapter 15; the five views of an architecture are discussed in Chapter 2 . |
Figure 10-8. Realization of an Interface

Figure 10-9. Realization of a Use Case

Use cases are discussed in Chapter 17; collaborations are discussed in Chapter 28 . |