# 20.5. Class Diagrams¶

The two major types of relationships between classes are association and inheritance. The Unified Modeling Language (UML) is a graphical notation that provides a standard for depicting classes and the relationships between them. It gives software engineers a way to record both their proposed designs, as well as the design of the final product. Put another way, UML provides the notation for constructing blueprints for software, and since it is widely used in both industry and academia, it is important for you to have some familiarity with it.

UML defines notations for several different kinds of diagrams. Here, we will introduce class diagrams, one of the most common UML diagrams. Class diagrams can contain a number of different elements, but we will focus on the basics: showing classes with their instance variables and methods, and the relationships between classes.

On a UML class diagram, a class is depicted as a rectangle with three sections. The top section contains the class name; the middle section, the instance variables (attributes); and the bottom section, the methods (behaviors). The following diagram shows the classes Point and LabeledPoint in an inheritance relationship where LabeledPoint is a child (subclass) of Point.

The class diagram below shows an association relationship between Point and LabeledPoint.