UML class diagrams

Personal notes

Raihan Kibria
3 min readMay 2, 2022

Diagrams made with the free Lucidchart app.

The class name should be in bold font.

Class member visibility (attributes and operations) is indicated by the prefixes +, - and #:

Attribute types follow after a colon:

Operation argument types and return types follow after a colon, argument direction can be indicated by prefixes in, out and inout:

For constructors and destructors the return type is empty:

For abstract classes the name and abstract methods are in italics.

Static class members (shared among all instances) are underlined.

Relationships

Inheritance

ChildClass “is a” (specialization of) ParentClass.

  • filled line with empty arrowhead from child to parent.

Realization / Implementation

RealizationClass implements InterfaceClass.

  • dashed line with empty arrowhead from realization to interface.

Aggregation

ContainerClass aggregates/collects (“has”) ContainedClass. Container and contained have different lifetimes (if the container is destroyed, the contained can live on).

  • solid line with empty diamond from container to contained.

Composition

Similar to aggregation, ContainerClass “has” ContainedClass but they have the same lifetime. The contained are destroyed when the container is destroyed.

  • solid line with full diamond from container to contained.

Document history

  • 02/05/22 First version. Class formatting & inheritance, realization, aggregation and composition relations.

--

--