Digging Deeper: Class Diagrams: Composition and Aggregation
Digging Deeper: Class Diagrams: Composition and Aggregation
All class diagrams have classes, links, and multiplicities. But a class diagram can show even
more information. We've already looked at generalization, aggregation, and navigability. In
this page, we will look at these additional items as well.
compositions
class member visibility and scope
dependencies and constraints
interfaces
This diagram shows that a BoxOffice belongs to exactly one MovieTheater. Destroy the
MovieTheater and the BoxOffice goes away! The collection of Movies is not so closely
bound to the MovieTheater.
Symbol Access
+ public
- private
# protected
The class diagram below is a model of a professional conference. The classes of interest to the
conference are SessionTalk, which is a single presentation, and Session, which is a one-day
collection of related SessionTalks. The ShuttleSchedule with its list of ShuttleStops is
important to the attendees staying at remote hotels. The diagram has one constraint, that the
ShuttleStops are ordered.
There are three interfaces in the diagram: IDated, ILocatable, and ITimed. The names of
interfaces typically begin with the letter I. Interface names along with their (abstract)
operations are written in italics.
The ShuttleStop class node has the stereotype << place>>. Stereotypes, which provide a
way of extending UML, are new kinds of model elements created from existing kinds. A
stereotype name is written above the class name. Ordinary stereotype names are enclosed in
guillemets, which look like pairs of angle-braces. An interface is a special kind of stereotype.
There are two acceptable notations for interfaces in the UML. The first is illustrated above. The
second uses the lollipop or circle notation.
In circle notation, the interfaces are circles with lines connected to the implementing classes.
Since it is more compact but leaves out some detail, the lollipop notation simplifies the original
diagram.