CS 743 - Software Verification and Validation

Fall 2019


Informal Semantics for UML Sequence Diagrams


This document describes the informal semantics for UML 2.0 (Unified Modeling Language version 2.0) Sequence diagrams. The document is intended to verify UML sequence diagrams and not to describe how to draw a sequence diagram. Consequently, the readers should refer to UML manuals or books for a detailed treatment of UML notations and how to use them.

UML Sequence Diagram

A sequence diagram in UML describes interactions of objects and is part of the dynamic view of a software system. The objective of a sequence diagram is to capture the sequence of interactions between objects in a particular scenario. It also includes the life lines of objects participating in a scenario. It is also possible to show creation and destruction of objects in a scenario. The life line also indicates temporal relationships of activities (timing at which the activities occur) and thus expresses the sequence of interactions between the objects. Notice that the interactions are between objects and not between classes and hence there can be more than one object from the same class participating in a scenario. The sequence diagram must be consistent with respect to the class diagram for the same application.

Notations - Summary

An UML sequence diagram is composed of the following notations:

 

Figure 1: UML Sequence Diagram Notations - Part 1

Figure 2: UML Sequence Diagram Notations - Part 2

Figure 3: UML Sequence Diagram Notations - Part 3

Figure 4: UML Sequence Diagram Notations - Part 4

Figure 5: UML Sequence Diagram Notations - Part 5

Informal Semantics

Sequence Diagram: A sequence diagram indicates the sequence of interactions between a selected subset of objects in the system. Typically, every sequence diagram individually represents a particular scenario in the application domain. It may be a part or whole of a use case, for example. Every sequence diagram is uniquely identified by its name preceded by the keyword 'sd'. The entire diagram is represented inside a rectangle with the diagram name at the top left corner. For convenience, some designers (and some UML tools) do not include the rectangle.

The following rules are applied to verify the sequence diagram notation:

Object:  An object in a sequence diagram has the same semantics of an object in an object diagram. It is represented as a rectangle with the name of the object followed by a colon followed by the class name to which the object belongs (e.g., s : Student). The object name and the class name are not case sensitive. Sometimes, the entire name of the object (including colon and the class name) may be underlined but it is a feature supported by the OO analysis and design tool. 

The following rules are applied with regard to the object notation:

Life line:  A life line shows for how long an object participates in a particular scenario (whether the object lives for the entire scenario, or created newly in this scenario or is destroyed in this scenario). It is represented as a vertical dashed line hanging from the object box.

The following rules govern the use of the life line symbol:

Execution Specification: When an object is active (doing something in the scenario such as sending a message or receiving a message), a solid rectangle is placed on top of the object's life line indicating that the object is active. UML 2.1.1. names this active portion of an object as execution specification.

The following rules are applied to the execution specification symbol:

Interaction:  An interaction in a sequence diagram represents a unidirectional communication between objects. There are four types of interactions used in a sequence diagram.

Asynchronous Message: This is represented by a solid arrow with an open arrow head. Being asynchronous, the object sending the message can do something else after sending the message; i.e., it does not wait for a response from the receiving object. An asynchronous message may have parameters. An asynchronous message is also called a 'stimulus'.

Method invocation: This is represented by a solid arrow with a solid arrow head. It has the same semantics as in programming languages for regular method calls and hence the sender will be blocked until there is a response from the receiver. This type of message may have parameters.

Return message: This is represented by a dashed arrow with an open arrow head.  It may represent a simple termination or confirmation from the receiver or it may also carry a return value. Additional documentation is necessary to explain the nature of return value by this interaction. Sometimes, a paired interaction may have a return variable specified in its label such as 'x = getName()'. Generally, a return message is not labelled. Earlier versions of UML use the label 'return' on top of the arrow. Some UML tools still use this convention.

Create message: This is a special type of method invocation which is represented by a dashed arrow with an open arrow head. It is used when one object wants to create a new object in a scenario. While this type of interaction has the same semantics as that of method invocation, the label on this message must represent the constructor of the object being created.

The following rules are applied on interaction symbols:

Alternate box: Interactions in a sequence diagram occur in the same order as they appear vertically in the diagram. So if an interaction A is placed above an interaction B, then A is said to occur before B. Sometimes, a user may want to choose a few interactions mutually exclusively from another set of interactions. In this case, the 'alt' box is used (the term 'alt' is a keyword). An 'alt' box is similar to an if-then-else block in a program. It encloses two sets of interactions, say A-set and B-set with a condition specified inside the 'alt' box. If the condition is true, one set of interactions, say the A-set, is included with the rest of the interactions in the diagram. If the condition is false, then the other set, in this case the B-set, is included with the rest of the interactions in the diagram.

The following rules are applied on 'alt' box:

Loop box: A set of interactions in a sequence diagram can be iterated, meaning that these interactions can be specified to occur repeatedly based on some condition. This is similar to a loop syntax in a program. The set of interactions to be repeated/iterated are enclosed in a loop box. The box has the keyword 'loop' along with an iterator specification. There is no standard syntax to specify an iterator. A sample iterator specification may include a for loop syntax or a while loop syntax.

The following rules are applied on 'loop' box:

References:

  1. Hans-Erik Erikson et al., UML 2 Toolkit, Wiley Publishing Company, 2004, ISBN: 0-471-46361-2.
  2. Russ Miles and Kim Hamilton, Learning UML 2.0, O-Reilly, 2006, ISBN: 0-596-00982-8.
  3. Alan Dennis et al., System Analysis & Design with UML, Wiley, 2012, ISBN: 978-1118037423.
  4. Bernd Bruegge and Allen H. Dutoit, Object-Oriented Software Engineering Using UML, Patterns and Java (3rd edition), Prentice Hall, 2009, ISBN: 978-0136061250.
  5. UML Standard documents published at the Object Management Group (OMG) web site:  www.omg.org/spec/UML.
  6. James Rumbaugh et al., The Unified Modeling Language Reference Manual, Addison-Wesley, 1999, ISBN: 0-201-30998-X.
  7. Hassan Gomaa, Software Modeling and Design, Cambridge University Press, 2011, ISBN: 978-0-521-76414-8.

Sample sequence diagram: