Learn UML Class Diagram In 15 Minutes

In this post, we will learn about UML class diagram. What is a UML diagram? How to read or create UML diagram representing different classes and relationships?

Introduction to UML Class Diagram

UML stands for Unified Modeling Language. It offers a way to visualize a system’s architecture in a diagram.

UML class diagram describes the structure of a system by showing the system’s classes, attributes, properties, methods and the relationship between various objects of the system.

DecisionMentor app
UML Class Diagram
A UML Class Diagram

Basics Of A UML Class Diagram

We can derive a lot of information from a UML class diagram.

Attributes Representation In UML

A class usually has one or many attributes which are also called properties or fields. For example a User class can have attributes such as username and password.

User Attributes In UML

We represent the attributes in the first box below the class name in a UML diagram. The data type and accessibility of each attribute is also defined here.

Operations Or Methods In UML

Operations are behaviors or actions of a class object. For example, a user object can have a method to validateUser.

Similar to Attributes, we define a method’s parameters type, return data type and accessibility.

Accessibility Level In UML

All attributes and operations have an accessibility level in a class. Some methods are private, while others are public. Yet, others are accessible only by the classes that derive from the parent class.

Accessibility LevelRepresentation In UML
Public– (minus sign)
Private+ (plus sign)
Protected# (hash sign)
Representation of private, public and protected methods and attributes in UML
Employee Class Diagram

Class Relationships With UML Class Diagram

Now we move onto next section which is defining relationships between classes with UML.

Inheritance Representation In UML

Inheritance is when a class derives from another class or interface. For example both the Developer and Designer classes can derive from Employee class.

In a UML Class Diagram, we use an Arrow symbol to represent Inheritance relationships.

Inheritance Representation With UML

Abstract classes can also be represented by Italics or <<ClassName>>.

Association Representation In UML

Two classes may be associated by a certain relationship. For example, a Student can be associated to a Teacher object. Similarly, a Developer can be associated with Project.

The associations can be of many types like 1 to 1, 1 to many or many to many.

We define an Association by a single line.

Association Between Developer And Project In UML

Composition Representation In UML

When a child object depends upon it’s parent object for its existence and cannot exist independently, then it implies a Composition relationship.

For example a ProjectMilestone object cannot exist if there is no Project class object.

We represent a Composition Representation with a Closed Diamond.

Aggregation Representation In UML

Unlike a Composition relationship, in an Aggregation relationship, the child can exist independently of parent object.

For example, a Project can be associated with a Department. Both can exist independently of each other. We define the Aggregation relationship by an Open Diamond figure in UML.

UML Class Relationship Representation


This post has covered all the basics that you need to know about UML class diagrams. We looked at a defining single class with attributes and operations. Then learnt about relationship diagrams for different types of class relationships. You should be able to read any UML diagram with this much knowledge!

Interested to learn mobile app development? Checkout out our articles and tutorials from Flutter section!