UML Communication Diagram cheatsheet

The Unified Modeling Language (UML) includes interaction diagrams with the purpose to illustrate how objects interact via messages. Interaction diagrams are used for dynamic object modelling. There are two common types: sequence and communication diagrams. Communication diagrams illustrate the interactions between objects in terms of sequenced messages. In this blogpost I will provide you with an overview of basic communication diagram notations and common patterns. You should this blogpost as a cheatsheet.

Content

A link is a connection path between to objects—it is an instance of an association. Note that multiple messages and messages in both ways flow along the same—single—link.

Links

Messages

Each message between objects is represented with a message expression and small arrow indicating the direction of the message. The best practise is to not number the starting message. However, even though it is legal to do, it simplifies the overall numbering if you do not do it.

Messages

Messages to itself

A message from an object to itself is illustrated by a link to itself, with messages flowing among the link.

Messages to itself

Creation of instances

The UML convention is to use a message named create to create an instance. It is legal to use another message name. If you do use another message name, you can—and should—annotate the message with a UML stereotype, in this case «create». Furthermore, you may optionally add the UML tagged value {new} to the lifeline box to highlight the creation.

Creation of instances

Message number sequencing

The order of messages is illustrated with sequence numbers. As stated before, the best practise is to not number the starting message, because you would create another level of number-nesting deeper than otherwise necessary.

The order and nesting of subsequent messages is shown with a legal numbering scheme in which nested messages have a number appended to them. Note that you denote nesting by prepending the incoming message number to the outgoing message number.

Message number sequencing

Conditional messages

A conditional message is shown by following a sequence number with conditional clause in square brackets. The message is only sent if the clause evaluates to true.

Conditional messages

Mutually exclusive conditional paths

With mutually exclusive conditional paths you must modify the sequence expressions with a conditional letter. By convention, the first letter used is a. The figure below states that either 1a or 1b could execute after msg1. Since either could be the first internal message, both are sequence number 1.

Mutually exclusive conditional paths

Iteration or looping

Iteration or looping

Iteration over a collection

Iteration over a collection

Asynchronous calls

Asynchronous calls are shown with a stick arrow; synchronous calls with a filled arrow, see the figure below.

Asynchronous calls

draw.io

All of above diagrams, are created with draw.io.

References

Larman, C. (2005). Applying UML and patterns: an introduction to object-oriented analysis and design and the unified proces (3th ed.) (pp. 240-247). Upper Saddle River (New Jersey): Pearson Education, Inc.


SHARE THIS ARTICLE