Class diagram

The Unified Modeling Language (UML) is a pictorial-based graphic modeling language designed to provide a standardized way to visualize the design of a system. It is commonly used in software development and object-oriented design. UML 2.3 offers 14 types of diagrams (9 in UML 1.3). UML is not a method, their use is left to the discretion of everyone, even if the class diagram is generally considered the central element of UML.

The class diagram is used in software engineering to present the classes and interfaces of the systems and the different relationships between them. A class describes the responsibilities, behavior, and type of a set of objects. The elements of this set are the instances of the class.

Classes can be related to each other thanks to the inheritance mechanism that makes it possible to highlight kinship relations. Other relationships are possible between classes, each of these relationships is represented by a specific arc in the class diagram.


A class is represented by a rectangle separated into three parts:

  1. the name of the class: it is written in « Roman » font, the abstract classes are written in italics or between << __ >>. The template classes have a rectangle whose border is dotted in their upper right corner (see picture below).
  2. the attributes of the class
  3. the methods of the class



The syntax of an attribute is: Visibility attributeName [multiplicity]: typeAttribute = Initialization;

The concept of visibility indicates who can have access to the attribute, it can take four values:

  • +: all other classes have access to this attribute (public access).
  • #: only the class and its inheritance have access to this attribute (protected access).
  • ~: class visible only in the package (private access).
  • -: only the class itself has access to this attribute (encapsulation principle with getter and setter).

The name of the attribute must not contain spaces, punctuation or accents. The multiplicity represents the number of times that the variable can exist for an object of the class.


An association is a relationship between two classes. It is described using:

  • roles of an object of one class in an object of the other (omitted if obvious);
  • cardinalities are numbers of objects of one class in an object of the other class; we use for this the notations:
    • 1
    • n, unknown at the time of compilation, but limited
    • 0..n means between 0 and n
    • 1..* means 1 or more
    • * means 0 or more
  • a type of oriented relationship;
  • optionally constraints on the association.

The types of relationships frequently encountered are:

  • Inheritance


  • Internal class


  • Dependance


  • Aggregate


  • Compose