The Class Diagram

The most basic of UML diagrams is the Class Diagram. It both describes classes and shows the relationships between them. The types of relationships that are possible are

  • When one class is a “kind of” another class: the is-a relationship

  • When there are associations between two classes

    - One class “contains” another class: the has-a relationship

    - One class “uses” another class

There are variations on these themes. For example, to say something contains something else can mean that

  • The contained item is a part of the containing item (like an engine in a car).

  • I have a collection of things that can exist on their own (like airplanes at an airport).

The first example is called composition while the second is called aggregation.[1]

Get Design Patterns Explained: A New Perspective on Object-Oriented Design now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.