Modeling sequence diagrams correctly – when, why and how?

Daniel Saffer

12/11/2018

Sequence diagrams Sequence Diagram) are used to dynamically model communication processes and interactions between system components.¹ The temporal progression takes on particular importance in this form of representation. This article is intended to help you model sequence diagrams correctly and meaningfully. It will cover the most common components.

Why use sequence diagrams?

Before you start modeling, you should already have knowledge of UML (Unified Modelling Language) or SysML (System Modelling Language) ². If not, we have some interesting articles on this topic (read moreAs already mentioned, a sequence diagram is a dynamic form of representation. Unlike static diagrams, it describes the processes and interactions of the system, software, or hardware. The diagram therefore shows the components that interact with each other or exchange information and the order in which this happens. Therefore, the vertical axis of the sequence diagram represents the time axis. The reading direction is from top to bottom. Using arrows in the horizontal direction, the communications or interactions between the components can then be represented. Sequence diagrams in SysML do not differ from those in UML. The following figure shows a sequence diagram that already contains the important  Modeling elements In the example, a user uses a keyboard to display numbers on a screen. When a key on the keyboard is pressed, a message is sent to the computer. To parse the message, the computer creates a new instance of the "Message Parser" class. It then receives the selected key and can check whether it is a number. If so, the number is displayed on the screen. If not, the string "not a number" appears.

Beispiel eines Sequenzdiagramms

Pros and cons of sequence diagrams

It doesn't always make sense to depict every system behavior as a sequence diagram. Therefore, you should always be clear about why you want to model something and what purpose the diagram should serve. The following pros and cons can help you decide whether to model or not.

Per:

  • Use cases can be presented in detail
  • Interactions and communication processes between system components and actuators become very understandable
  • Behavioral decisions can be made using sequence diagrams
  • Comparison of the actual state with the desired state
  • Very well suited for documenting test cases
  • Dealing with complex logic, processes or methods

Cons:

  • Sequence diagrams only represent a snapshot of the system under certain circumstances
  • Very high maintenance effort when changes to system behavior occur
  • Impossible to display every snapshot
  • Modeling a behavior that is not realized in reality
  • Sequence diagrams tend to quickly become complex and unreadable

Use cases of sequence diagrams

Sequence diagrams also have different use cases. In medical device development, sequence diagrams are particularly suitable in the following scenarios:

  • Behavior of methods: During software development, sequence diagrams are primarily used to model the functionality of methods or functions. Modeling can be reversed or used to make decisions about method design.
  • Timeline of test cases: Documenting test cases is also important for later reproducing tests and potential errors. A sequence diagram can be used to describe the chronological flow of the tests. A picture is often worth a thousand words. Remember to keep the diagram as simple as possible so it's easy to read and understand.
  • System use cases: Sequence diagrams can also be used at the highest modeling level, the system level, to map the system's use cases. Particularly difficult or unclear use cases can be documented this way.

Components of sequence diagrams

Sequence diagrams cannot be created entirely without theory. UML and SysML specify symbols, elements, and their names. We will now discuss the most important symbols and elements. Using these symbols, you can create readable sequence diagrams independently.

Images can be clicked to enlarge.

symbol name Description
Lifeline A lifeline is a participant or component of the current representation. Lifelines can be interacted with and information exchanged. Interactions between participants or components are represented by arrows (see asynchronous and synchronous arrows).
actor An actor is a user of the system. Actors can be human users, but also machines, other systems, or subsystems. Anything that interacts with the system outside the system boundary is also referred to as an actor. Further information on actors and the system context and system boundaries can be found here: https://medtech-ingenieur.de/category/systemarchitekten/
Border A boundary can be used to model the system boundary. The interfaces specified in the system context diagram can be used here. Boundaries can also be implemented as lifelines using the stereotype "boundary" or "interface."
Activity bar Activity bars represent how much time a component takes to complete a task. The longer an execution takes, the longer the activity bar becomes. The figure above shows that completing the entire task (key press ⇾ display) naturally takes the most time.
Asynchronous message Asynchronous function calls or messages are represented by a solid line and a hollow arrowhead. The function call and input parameters can be written above it.
Synchronous message Synchronous function calls or messages are represented by a solid line and a filled arrowhead. The function call and input parameters can be written above it.
return If the return is a function return or a return in general, a dashed arrow pointing in the opposite direction with a blank arrowhead can be used. Return parameters can be written above the arrow.
New When a new instance of an object is created, a dashed arrow with an empty arrowhead and the stereotype < > be used.
Delete If an instance is deleted, this can be indicated by the delete symbol. From this point on, the participant or component no longer exists. For example, see the figure "Message Parser."
Fragments Fragments are used to generally influence processes. Fragments can implement while loops or if-else conditions. Different terms, such as "alt," are used for this purpose and are inserted into the fragment. The most important terms are:

  • alt == alternative or If-Else
  • assert == assertion
  • break
  • consider
  • critical == critical region
  • ignore
  • loop (e.g. while loop)
  • neg == negative
  • opt == option
  • par == parallel
  • ref == link
  • seq == weak sequencing
  • strict == strict sequencing

Tool for creating sequence diagrams

MEDtech-Ingeneur uses the Enterprise Architect tool. Enterprise Architect is a paid tool from Sparx Systems and can be used to create diagrams in SysML, UML, and other modeling languages. The tool is very well suited for systems development². Documentation can be generated automatically. The tool can be downloaded here as a free trial. downloaded and bought here become.

¹ Learn more about system components in this article: https://medtech-ingenieur.de/systeme-in-der-medizintechnik-sinnvolle-grenzen-setzen/ 

² Creating system architecture correctly with UML and SysML: https://medtech-ingenieur.de/system-architektur/ and https://medtech-ingenieur.de/sprechen-sie-sysml/


Written by Daniel Saffer

Daniel Saffer is Chief Technical Officer (CTO) of MEDtech Ingenieur GmbH. In this role, he is responsible for the company's technical strategy and supports customer projects in medical technology. His focus is on the further development of safety-critical software solutions, regulatory requirements, and innovative technologies for the industry.


More articles

  • 19/03/2025
  • General, Companies, Events

We are pleased to invite you to an exclusive VDI event of Network Systems Engineering, which will take place in our office!On Friday, March 28, 2025, everything will be about the ...

Read more
  • 05/12/2024
  • General, Systems Engineering, Companies, Events

In a constantly changing business world, creativity is a key factor for success. Companies that can develop innovative solutions and continuously adapt to new challenges have a ...

Read more
  • 09/07/2024
  • General, Electrical Stimulation, Systems Engineering, Companies, Events

Dear engineers, technology enthusiasts, and family members, the "Fascination of Technology" family day will take place in Nuremberg on July 13, 2024! The event is organized by the VDI District Association Bavaria Northeast and the Nuremberg Technical University. ...

Read more
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

Strictly Necessary Cookies

Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.