Page: (Bot) (Prev) (Next)   Class: (Outline) (Summary) (Assign) (Answer)   Course: (Content)

To: (Purpose) (Components) (Related) (Example)

Model Type (Top)


Purpose (Top)

A class diagram shows:

  1. The classes that are required to solve the problem. Each class in the model usually contains:
    1. The class name (required).
    2. The class attributes and the instance attributes.
    3. The class operations and the instance operations.
  2. The relationships between classes (inheritance).
  3. The relationships between object instances (associations and aggregations). These may include various adornments that describe the relationship.
It is quite common to suppress "trivial" details on an object model so that its true meaning is more obvious. However, the missing details must be documented, usually by means of dictionaries and textual descriptions.

Components and Structure (Top)

We will use the Unified Modeling Language (UML) for class diagrams. Figure 1 shows the major components of a UML class diagram:

Figure 1: ULM Class Diagram Components

Figure 2: Association Adornments
Association Adornments

As shown in Figure 2, an association may contain various adornments. An association role is simply the end of an association where it connects to the class. Each end of an association is a role. A role is a part of the association, not part of the class. The association path may have graphical adornments on each end to specify properties of the role.

The adornments are:

Figure 3: Association Attributes
Association Attributes

An association may have its own attributes. These attributes exist only if an instance of the association exists. This is illustrated in Figure 3. The attributes salary and jobTitle exist only if there is an instance of a Works-for association between a Person and a Company.

Figure 4: Assoication Classes
Association Classes

If the association also has behavior, then the association has all of the properties of a class. This is illustrated in the next diagram were the association attributes have been promoted to an association class named Job that has an operation that allows the salary to be changed.

Related Models (Top)

Example (Top)

The following figure is an example of a class diagram:


You would read this model as follows:

A Building is owned by one Person. A Person may own more than one building, but based on the navigation arrow, a Person does not know about those buildings. Each Building is either a House or an Apartment. An Apartment contains two or more RentalUnits.

It is possible to Buy a House or an Apartment, and Rent or Vacate a RentalUnit.

The model also shows some attributes for each object but the attributes were not included in the discussion.

This next model shows aggregation and association:


In the figure, a company is an aggregate of divisions which is an aggregate of departments. But a person is associated with the company as an employee and also with a department through an assignment. The division depends on the company for its existence. But the association between a person and a department can change.

Page: (Top) (Prev) (Next)   Class: (Outline) (Summary) (Assign) (Answer)   Course: (Content)

Prepared by David L. March -- Last Revised on October 1, 2001