Definition
Class Diagram ( UML)
In software engineering, a class diagram in UML is a type of static structure diagram that describes the structure of a system by showing the system’s classes, their attributes, operations (or methods), and the relationships among objects.
Class
A class is divided into three segments:
- class name (class name, class stereotypes)
- attributes
- operations
Example:

Attributes
- Every attribute must have a unique name in the scope of a class.
- Every attribute could have a type assigned to it.
Attribute Syntax

Attribute Accessibility
| Symbol | Meaning |
|---|---|
| + | public |
| - | private |
| # | protected |
| ~ | package |
Derived Attribute
Derived attributes, i.e. attributes that are derived from other attributes, are prefixed with a ”/” (slash).
Example: age

Attribute Multiplicity
Attributes can have a certain multiplicity, i.e. a certain number of values that can be held by a single attribute.
It’s denoted using notation. A ”*” (star) can be used as max to denote that there’s no upper limit (”*”, or “[0..*]).
Example: address

Attribute Properties
Properties can be assigned to attributes, such as:
- {readOnly}
- {unique}, {non-unique}
- {ordered}, {unordered}
Examples: address, ssNo

Instance Attribute
An instance attribute is an attribute that is defined on instance level. Every object instance of a class could have a different value.
Class Attribute
A class attribute is an attribute that is defined on class level. A class has only one value assigned to it. It’s analogous to static attributes in programming languages, like Java.
Class attributes are denoted as underlined attributes.
Example: personsNumber

Operations
Operation Syntax

Parameter Syntax

Parameter Directionality
| Notation | Meaning |
|---|---|
| in | input parameter |
| out | output parameter |
| inout | combined I/O parameter |
Class Operation
Analogous to class attribute, but for operations.
Instance Operation
Analogous to instance attribute, but for operations.
Stereotype
Stereotypes are an extension to standard UML. They are denoted as . Using stereotypes, concepts from database modelling can be introduced, such as primary keys.
Stereotypes can be used on class-level, attribute-level, and operation level.
Note that the extension only specifies the possibility of stereotypes, i.e. interpretation of certain stereotypes are not standardised.
Example:

Association
Associations between classes model possible links between instances of those classes.
Example:

Association Multiplicity
Possible notations are:
- Interval: “min..max”
- Arbitrary: ”*”
- Listing: “(x, y, z)” - read as either x, y, or z
- (3, 6..9) is also possible
Binary Association
Example:
- A professor gives lecture for students.
- The tip of the arrow on the professor side denotes that a students can access the professor via the public
lecturerattribute. The professor, however, can’t access the students. - One professor is connected to students (”*” - multiplicity).
- One student is connected to professors (”*” - multiplicity)

n-ary Association

Exclusive Association
An exclusive (xor) association is given if, for a certain object at a certain time, there’s only one possible association.
Example: An exam is either associated with an office or with a lecture hall, never both.

Association Class
An association class may include attributes of an association.
Trivially, an association class is necessary for m:n associations. For 1:1 or 1:n associations, they aren’t necessary.
Example:

Association Order
- unordered
- ordered
Association Uniqueness
- unique
- non-unique
Aggregation
Aggregation is a special form of association for whole-part relationships.
Properties:
Weak Aggregation
Shared Aggregation

Example:

Strong Aggregation
Composite Aggregation

Example:

Generalisation

Multi-Inheritance

Abstract Class
An abstract class is a special form of a class which can’t be directly instantiated. A specialisation class should be used to instantiate it.
Abstract class names should be prefixed by “{abstract}” or written in italic.

Example: Shape can’t be instantiated. It’s either Cylinder or Dice.

Complete Generalisation
A complete generalisation is a form of generalisation where every object of a certain parent class is at least one of its specialisations.
Incomplete Generalisation
An incomplete generalisation is a form of generalisation where there are objects that are not instanced of any specialisation.
Disjoint Generalisation
A generalisation is disjoint if all specialisations don’t overlap.
Overlapping Generalisation
A generalisation is disjoint if some specialisations overlap.
Data Type
In contrast to objects, data types don’t have an id and are thus not comparable by instance.
They are denoted with a prefix in its name.

Primitive Data Type
A primitive data type are data types without internal structure.
Standardised:
- Boolean
- Integer
- UnlimitedNatural
- String
More primitives can be defined using the keyword.
Data Type with Attributes and Operations
Enumeration Type
An enumeration type’s domain is defined by an enumeration of possible values.
Enumerations can be defined using the keyword.
Example:
