UML Quick Reference

Class Diagrams, Sequence Diagrams, Activity Diagrams easily explained and summurized — just in case of need.

Federico Haag
4 min readNov 22, 2017

Contents of the Article

  1. Introduction of UML
  2. Class Diagram
  3. Sequence Diagram
  4. Activity Diagram

Introduction of UML

The Unified Modeling Language (UML) is a modeling language that is intended to provide a standard way to visualize the design of a system (generally a software) through an object oriented diagram scheme.

UML is recognized by the International Organization for Standardization (ISO) as the industry standard for modeling software-intensive systems.

UML is composed by many different types of diagrams, each one designed for a specific modeling goal. This article presents the most used ones in daily development life, while the complete and updated reference can be found in the official website at http://www.uml.org/ .

1. Class Diagram

Class Diagram is one of the types of UML diagrams which are part of Structure Diagrams category.

Class Diagrams describe the structure of the system we want to model by showing the system’s classes, their attributes, operations (or methods), and the relationships among them.

Syntax

A class is represented by a box containing the class name, attributes and methods. These three are divided by a line in three rows.

At the left of the attribute / method name is represented the visibility: “+” standing for “public”, “-” standing for “private”, “ #” standing for “protected”, “~” standing for package.

Boxes (=classes) are connected with rows representing various types of relationships:

  • Association relationship: is a general one.
  • Inheritance relationship: connects a subclass with its own parent class (see OOP inheritance paradigm) from which inherits all attributes & methods.
  • Realization relationship: connects a class with the interface wich implements (see OOP interface implementation).
  • Dependency relationship: connects a class with another one that is strictly needed by the first in order to achieve its tasks.
  • Aggregation relationship: connects a class with another one that’s a part of it due to the software / database structure previously projected. For example in diagrams of an OOP class, a variable could be not a general String or Intege but a particular class. In this case the class you are defining has an “aggregation relationship” with the class of that variable.
  • Composition relationship: connects a class with another one that — physically in the real world — is part of it.

In every relationship, at the beginning and at the ending of the line, it is indicated the multiplicity:

Course can be attended by 3 to 10 students. “3..10” is written near Student. Each student can attend no courses or many ones: “0..*” is written near Course. Note that * means “any number”.

2. Sequence Diagram

Sequence Diagram is one of the types of UML diagrams which are part of Interaction Diagrams category.

Sequence Diagrams are used to describe in time sequence how the involved classes operate with themselves and which messages are exchanged during a specific scenario that could happen in the analyzed system.

Syntax:

The involved classes are represented by blocks at the top of the diagram.

Under each block, a vertical line is drawn representing its process.

The messages exchanged between the processes, are represented through orizontal arrows. Lines’ arrows’ heads describe the sender/receiver relationship of the message:

  • Solid arrow head represents a synchronous call.
  • Open arrow head represents an asynchronous call.
  • Dashed arrow line represents a response message.
  • An arrow starting from a filled-in black dot not aligned with any process, represents a message received from a class not mentioned in the diagram.

This is an example of what you could build with a Sequence Diagram:

credits image: https://en.wikipedia.org/wiki/Sequence_diagram

The destruction of a process is represented inserting an “X” in its line process, in the position where the destruction happens. Note: the diagram is in time sequence, so the X is always at the end of the process line.

3. Activity Diagram

Activity Diagram is one of the types of UML diagrams which are part of Behaviour Diagrams category.

Activity Diagrams describe a system process through the graphical representation of the workflow of its stepwise activities and actions.

Syntax:

The process start with a black filled dot, and it ends with an encircled one. The flow is represented by a sequence of arrows and blocks, representing activities and logical conditions. Iteration is allowed inside the diagram.

The following are the types of shapes that can be included inside an Activity Diagram:

  • Rounded rectangles represent actions.
  • Diamonds represent a split point based on a question written close to the diamond symbol. The possible answers must be written near the corresponding arrow.
  • Bars represent the start (split) or end (join) of concurrent activities.

This is an example of what you could build with an Activity Diagram:

credits image: https://en.wikipedia.org/wiki/Activity_diagram

Activity diagrams can be used to model not only software systems but also organizational processes, even if in practice it is more common the usage of BPMN notation.

--

--