About

UML Class Diagrams and Notation

UML Class Diagrams and Notation

The Unified Modeling Language (UML) class diagram provides a standard visual representation of classes and their interrelationships.

The 3 Compartments of a Class Box

A standard UML class box is split into three horizontal sections:

  1. Top: Class Name (italicized if abstract, or prefixed with «interface» if an interface).
  2. Middle: Attributes (e.g. - balance: double).
  3. Bottom: Operations / Methods (e.g. + deposit(amount: double): void).

Visibility Modifiers

SymbolVisibilityDescription
+PublicAccessible from any class
-PrivateAccessible only within the declaring class
#ProtectedAccessible within package and subclasses
~Package-privateAccessible only within the same package

Multiplicity Notation

Multiplicity indicates how many instances participate in a relationship:

Exercise 1

In a UML diagram, what does the symbol - preceding an attribute denote?

Show solution ↓
Solution

It denotes private visibility, indicating the member is encapsulated and inaccessible to outside callers.