A class diagram shows the static class structure, they are used when developing an object-oriented system model to show the classes in a system and the associations between these classes.
It consists of:
Class (UML Class)
An object class (or just class) which can be thought of as a general definition of one kind of system object.
Link to originalgraph { node [shape=record] Course CourseCoarse [label = <{<b>Course</b> | name<br align="left"/>semester<br align="left"/>hours<br align="left"/>|getCredits()<br align="left"/>getLecturer()<br align="left"/>getGPA()<br align="left"/>}>] CourseFine [label = <{<b>Course</b> | + name: String<br align="left"/>+ semester: SemesterType<br align="left"/>- hours: int<br align="left"/>- /credits: int<br align="left"/>|+ getCredits(): int<br align="left"/>+ getLecturer(): Lecturer<br align="left"/>+ getGPA(): float<br align="left"/>+ getHours(): float<br align="left"/>+ setHours(hours: float): void<br align="left"/>}>] }Object (UML Class)
Objects are instances of classes.
graph { node [shape=record] Class [label=<{<b>User</b> <br align="left"/>| + ID: int<br align="left"/>+ name: String<br align="left"/>+ address: String<br align="left"/>}>] Object [label=<{<b>deez:User</b> <br align="left"/>| ID = 0044<br align="left"/>name = "deez"<br align="left"/>address = "123 Fake Street"<br align="left"/>}>] }Attribute (UML Class)
Attributes define the structural characteristics of a class, each instance / object has a different value.
Link to original
Link to originalOperation (UML Class)
An operation is the behaviour of a class, it is identical for all objects of a class, they are not depicted in the object diagram.
Link to originalAttribute Syntax (UML Class)
Each attribute follows a certain syntax which is built up using the following structure:

- Visibility: who is permitted to access the attribute
+: public / everyone-: private / only the object itself#: protected / class itself and sub-classes~: package / classes that are in the same package
- Derived:
/is specified if the attribute value is derived from other attributes - Name: name of the attribute
- Type: it may be one of:
- Another user-defined class
- Predefined primitive data type (Boolean, Integer, String)
- User-defined primitive data type: «primitive»
graph { node[shape=record] Float [label=<{«primitive» <br align="center"/><b>Float</b> <br align="center"/>| round(): void<br align="left"/>}>] } - Composite data type: «datatype»
graph { node[shape=record] Float [label=<{«datatype» <br align="center"/><b>Date</b> <br align="center"/>| day<br align="left"/>month<br align="left"/>year<br align="left"/>}>] } - Enumeration: «enumeration»
graph { node[shape=record] Float [label=<{«enumeration» <br align="center"/><b>AcademicDegree</b> <br align="center"/>| bachelor<br align="left"/>master<br align="left"/>phd<br align="left"/>}>] }
- Multiplicity: number of values an attribute may contain
- By default, we take it to be .
- Notation is .
- No upper limit may be indicated by or .
- Default value: used if the attribute value is not set explicitly by the user
- Properties: additional restrictions on attributes
- Predefined properties that may be used:
{readOnly}: value cannot be changed{unique}: no duplicates permitted{non-unique}: duplicated permitted{ordered}: fixed order of the values{unordered}: no fixed order of the values
- Common attribute specifications:
- Set:
{unordered, unique} - Multi-set:
{unordered, non-unique} - Ordered set:
{ordered, unique} - List:
{ordered, non-unique}
- Set:
- Predefined properties that may be used:
- Visibility: who is permitted to access the attribute
Operation Syntax (UML Class)
Each operation follows a certain syntax which is built up using the following structure:

- Visibility: see Attribute Syntax (UML Class)
- Name: see Attribute Syntax (UML Class)
- Parameter: similar notation to attributes:
In addition, a direction may be specified:
in: input parameter When the operation is used, a value is expected from this parameter.out: output parameter After the execution of the operation, the parameter has adopted a new value.inout: combined input / output parameter
- Type: type of the return value
Association (UML Class)
An association: link between classes that indicates that there is some relationship between these classes.
Link to originalgraph { rankdir=LR node[shape=rectangle] Lecturer--Course }Binary Association (UML Class)
A binary association is an association between two classes where an instance of one class must know about the other in order to perform its work.
- Role names and multiplicities are labelled at both ends.
- In uni-directional associations, role name at the start of the arrow is optional.
- Can be used to formalise requirements such as “each professor may coach a set of students, and each student is coached by exactly one professor”

Multiplicity (UML)
The multiplicity is the number of objects that may be associated with exactly one object of the opposite side.
UML Notation Meaning any number of objects (incl. zero) at least one object exactly one object exactly objects at least and at most objects graph { rankdir=LR node [shape=rectangle] Lecturer--Assignment [taillabel="1" label="issues" headlabel="*"] } Link to originalgraph { rankdir=LR node [shape=rectangle] Lecturer--Assignment [taillabel="1..*" label="gives" headlabel="1..*"] }
Link to originalRole (UML Class)
The role describes the way in which an object is involved in an association relationship.
Link to original
Unary Association (UML Class)
A unary association is between a class and itself.
Link to originalgraph { node[shape=rectangle] Person--Person [taillabel="0..1" label=" is married to"] Employee--Employee [taillabel="+manager 1" headlabel="+staff 1..*" label=" manages"] }Association Class (UML Class)
An association class allows us to assign attributes to the relationship between classes rather than to a class itself.

This is necessary when we are modelling n:m associations.
Link to original
Aggregation (UML Class)
An aggregation is a special form of association used to express that a class is part of another class, properties of the aggregation association include:
- transitive: if is part of and is part of , is also part of
- asymmetric: it is not possible for to be part of and to be part of at the same time
There are two types:
Shared Aggregation (UML Class)
A shared aggregation expresses “a weak belonging of the parts to a whole” where parts also exist independently of the whole. Multiplicity at the aggregating end may be hence one element can be part of multiple other element at the same time. Syntax is a hollow diamond at the aggregating end.
For example, take that:
- a Student is part of LabClass
- a Course is part of StudyProgram
Link to original
Composition (UML Class)
A composition is an existence dependency between the composite object and its parts. One part can only be contained in at most one composite object at one specific point in time. Multiplicity at aggregating end is at maximum 1, the composite objects form a tree.
If the composite object is deleted, its parts are also deleted. Syntax: solid diamond at the aggregating end.
For example, a Beamer is part of LectureHall which is part of Building.
Link to original
Generalisation (UML Class)
A generalisation is where:
- characteristics (attrs / ops), associations, and aggregations that are specified for the super-class are passed on to its sub-classes
- every instance of a sub-class is at the same time an instance of the super-class
- sub-class inherits all characteristics, associations, and aggregations of the super-class except private ones
- sub-class may have further characteristics, associations, and aggregations Generalisations can also be transitive.

UML allows multiple inheritance, so a class may have multiple super-classes.
Link to original