The sequence diagram is a diagram from the Unified Modeling Language (UML). UML is an object-oriented modeling language. This kind of language consists of graphic elements. UML models systems and processes of object-oriented pro­gram­ming, as well as business processes. The aim is to present complex facts in such a way that they will be easily un­der­stood. UML has a stand­ard­izised notation for this purpose. A certain form will always stand for a certain component or a certain behaviour. The so-called metamod­el­ing defines language units and their meaning within the UML. This also includes de­term­in­ing how certain elements interact with each other, and which hier­arch­ies exist between language units.

Elements and re­la­tion­ships are rep­res­en­ted in UML in the form of diagrams. UML2 dis­tin­guishes 14 different types of diagrams. These get assigned to one of three different cat­egor­ies: structure diagrams, behaviour diagrams, and in­ter­ac­tion diagrams.

Structure diagrams represent a system and its com­pon­ents in a static state. They il­lus­trate the re­la­tion­ships between in­di­vidu­al elements or between elements and su­per­or­din­ate concepts. An example of this is the class diagram.

Behaviour diagrams represent processes and the behaviour of a system. In contrast to structure diagrams, the sequence of processes and time also plays a role in the rep­res­ent­a­tion. An example of this is activity diagrams.

  • In­ter­ac­tion diagrams are a subset of be­ha­vi­or­al diagrams. They are listed sep­ar­ately because they model a specific behavior – namely the in­ter­ac­tions between system elements. The basic building blocks of in­ter­ac­tions are the so-called 'life­lines.' These are objects (the smallest in­de­pend­ent building blocks of object-oriented pro­gram­ming) that represent in­di­vidu­al par­ti­cipants in an in­ter­ac­tion. The most commonly used in­ter­ac­tion diagram is the sequence diagram.

Sequence diagrams: uses and special features

The UML sequence diagram displays events in chro­no­lo­gic­al order. This is why it is sometimes referred to as an event diagram or event scenario. The exact order of the events is the most important element. However, you can add re­stric­tions to your model. For example, a time limit for a par­tic­u­lar process (such as entering a PIN at an ATM) can trigger the actions for an event (card issuance if no input is made after a certain time).

The sequence diagram basically describes how objects exchange messages in a certain order. Objects are the basic building block of UML diagrams. Depending on the diagram type, they represent certain char­ac­ter­ist­ics of a system element. In in­ter­ac­tions, the objects are lifelines.

Requests are made and responses are sent con­stantly within one system. The recipient makes a decision based on the specific request and the pre-defined rules of the recipient. This kind of network of possible decisions and in­ter­ac­tions is usually rep­res­en­ted by an activity diagram. If you imagine all possible decisions (yes/no) as a tree diagram, you’ll probably be imagining a highly branched network. The sequence diagram only shows a specific path within this network.

The sequence diagram differs from the UML ap­plic­a­tion case diagram in par­tic­u­lar by its detailed order. If a new business process is to be in­tro­duced, the ap­plic­a­tion case provides a good overview of the re­quire­ments. If, on the other hand, you want to define specific cases and a schedule, you create a sequence diagram. Here, you can display in­di­vidu­al subareas in more detail. With this so-called ap­plic­a­tion scenario, you put the logical con­nec­tions of your ap­plic­a­tion case through their paces.

UML sequence diagrams are also useful when you want to graph com­plic­ated processes for better un­der­stand­ing. The clear modeling allows you to quickly identify which stations a single task must go through in order to be suc­cess­fully completed. This allows you to plan and test your methods before they are im­ple­men­ted in everyday business or in a computer system.

To represent the control struc­tures of a higher pro­gram­ming language, connect several sequence diagrams together in a combined fragment.

Note

Sequence diagrams support logical analysis for parts of systems. If the time sequence of processes plays an important role, this diagram type is very well suited to this. However, it does not make sense to represent a whole system with it. Instead, it is instead better to refer to a suitable be­ha­vi­or­al diagram such as the use case diagram, the state diagram, or the activity diagram. These il­lus­trate even larger contexts clearly and simply.

UML sequence diagrams: notation and examples

A UML diagram should help everyone un­der­stand complex systems better. The modeling language uses visual symbols for this purpose. UML can be adapted for ex­cep­tions and certain ap­plic­a­tion groups. However, it makes sense to mainly use the language specified by the Object Man­age­ment Group (also known as OMG). Otherwise, the whole point of using a diagram, i.e. to make complex systems un­der­stand­able, will be lost, as the diagram will be in­com­pre­hens­ible. The following spe­cific­a­tions cor­res­pond to the UML standard in version UML 2.5.

Lifelines

The lifeline rep­res­ents the course of time for a process. The head of a lifeline consists of a rectangle. This usually contains the object name and the class name. If the object name is missing, the lifeline stands for an unnamed instance of the object. In this case, you can assume that all objects of the same class act equally in this sequence. The lifeline always stands for a single operand. If the operand has several char­ac­ter­ist­ics, one of them must be selected. Al­tern­at­ively, it can also be said that the mul­ti­pli­city is never >1.

Fact

In computer tech­no­logy, an operand is an object that is in­flu­enced by an operator. Operands can be constant or variable. For example, a simple operand is the variable X. Operators can be simple arith­met­ic operators such as ‘+’ and ‘-’. In pro­gram­ming, these com­pon­ents are used for simple functions such as ‘x = t * 4’, as well as soph­ist­ic­ated al­gorithms.

A dashed line goes down from the rect­an­gu­lar head. This line rep­res­ents the course of time. Time is depicted linearly, moving downwards. Messages are sent and responses given along the timeline. A message to be sent after another message is at the bottom of the timeline. The notation is never about clear times, but always about the order, and messages are always arranged one below the other, unless they exist in parallel combined fragments.

Lifelines indicate how long an object is actively involved in a process. This is shown by how long one lifeline is compared to the others. Some objects are destroyed before the process is over. Objects that are no longer required are marked on their lifeline with an 'X' at the point where they should be destroyed.

A sequence diagram is well suited to checking how failsafe your system is. Three class ste­reo­types of the lifeline can be used for this purpose:

  • Entity
  • Border
  • Control

At the top of the picture you’ll see the three lifelines including notation: The entity has a round head that lies on a ho­ri­zont­al line. At the border, a line goes off the middle of the circle and connects with a vertical line – like an upturned T that goes off to the side of the head. The head of the control consists of an arrow that rotates in a circle. From all these class ste­reo­types, the dashed lifeline decreases ver­tic­ally downwards.

If you have already worked out a concept using a use case diagram, the sequence diagram can help you work out the in­di­vidu­al steps, taking into account the con­ceiv­able actors and objects.

Bound­ar­ies stand for in­ter­faces that interact with external actors. These objects can be, for example, user in­ter­faces – in which case the actor would be a person. Entities, on the other hand, stand for data con­tain­ers or objects that contain system data. For borders and entities to com­mu­nic­ate, you need a control element. The control does not ne­ces­sar­ily have to be an object. A method at­trib­uted to one of the other two elements also works. The control element connects entity and boundary as a mediator. It monitors the signals of both elements and checks them for logic.

  • The three ste­reo­types com­mu­nic­ate according to four rules – border objects are the interface re­spons­ible for com­mu­nic­a­tion with actors. Actors com­mu­nic­ate ex­clus­ively with borders.
  • In contrast, control objects com­mu­nic­ate with other control objects as well as with entities and bound­ar­ies. In return, they do not interact with actors.
  • Borders com­mu­nic­ate with control objects and with actors.
  • Entities are rooted deepest in the system as data carriers. You only exchange data with control objects.

Messages

The message is a basic element of a UML sequence diagram. In object-oriented pro­gram­ming, a system consists of objects. UML displays these objects as nodes that are connected by so-called edges (also sometimes known as paths or flows). In UML, these kinds of edges perform different tasks. In the UML sequence diagram they model metaclass messages. The notation specifies a line as the basic form of the edge. Arrows are a special form of edges that represent a dir­ec­tion­al re­la­tion­ship or a flow of in­form­a­tion. In the sequence diagram, they symbolise messages. Various message types are displayed dif­fer­ently, as can be seen in the figure below.

Name the message with a label showing its contents. For simple messages use the following form:

[message name] : [attribute '='] signal name or operation name[arguments] [':' return value]

Valid arguments for messages are:

    • Constants
    • Wildcard values (symbolic values rep­res­ent­ing a legal value X in the diagram)
    • At­trib­utes of the sender
    • Para­met­ers of the sur­round­ing in­ter­ac­tion
    • At­trib­utes of the su­per­or­din­ate class

Messages have a signature which specify the content of the message. The signature refers either to a signal, or an operation and must be named after it. This means that the content of the message either triggers an operation (an activity) at the recipient end, or sends a signal – i.e. only exchanges in­form­a­tion. Messages also differ in whether they are syn­chron­ous or asyn­chron­ous. With asyn­chron­ous messages, the sender does not wait for a reply, but im­me­di­ately resumes its behaviour. Syn­chron­ous messages wait for a reply and block the channel on which they are trans­mit­ting.

These are the stand­ard­ised message types in the UML sequence diagram:

  • Asyn­chron­ous messages of the type (Mes­sage­Sort) asynch­C­all, connect to an operation and trigger its execution. With asyn­chron­ous messages, the system does not wait for a response from the recipient, but continues its processes without in­ter­rup­tion. Operation para­met­ers and message at­trib­utes must match.
    • Notation: You model asyn­chron­ous messages as an arrow with a con­tinu­ous line and an open arrowhead.
    • Sending and receiving asyn­chron­ous messages: This kind of message results from an asyn­chron­ous trans­mis­sion action of the signal. In this case, the signal at­trib­utes determine the message arguments.
  • Syn­chron­ous messages only request op­er­a­tions, not signals. The message type is synchCall. Syn­chron­ous messages wait for a response from the operation before resuming their behaviour. Syn­chron­ous messages are displayed as an arrow with a filled arrowhead.
  • Reply – the recipient of a message sends a reply back to the sender after the operation has come to a result. The symbol for this has an open or a filled arrowhead. The cor­res­pond­ing line is dashed.
  • cre­ateMes­sage is a message type that signals a new instance of a lifeline. The system creates a new object in the sequence diagram. This message type is the only one that refers directly to the head of the lifeline. Other messages must point to the dashed life line. cre­ateMes­sage has an arrow with open tip and dashed line like the response, but pointing in the opposite direction.
  • de­leteMes­sage signals the point runtime at which a lifeline instance is destroyed. You draw the deletion message as an arrow, with the title <>> (this is optional). It must always point to a de­struc­tion oc­cur­rence spe­cific­a­tion. Also called a de­struc­tion event, this event oc­cur­rence spe­cific­a­tion marks the de­struc­tion of an object on the runtime line with an 'X.'

Messages of any type can be missing a sender or recipient – and in this case they are unknown. The UML stand­ard­ised languages then assumes that the re­spect­ive instance lies outside the diagram described. If you know the recipient, but not the sender, the message is found. Where you would otherwise model the sender, a small, filled circle indicates this absence. With a lost message, the opposite is true: if you do not know the recipient, model a filled circle at the arrowhead.

Messages sent on their own lifeline have a special form. The lifeline then sends the recursion from an activity bar. While the ac­tiv­a­tion is still running, a new ac­tiv­a­tion starts on the same lifeline. Their starting point is the sent message, and you use this type of message, for example, if an operation is performed several times. Now, the object must refer to itself. Messages between two lifelines can also cause over­lap­ping ac­tiv­a­tions. The spe­cific­a­tions of ac­tiv­a­tions are described in more detail below.

Another important part of the message is its parameter. Para­met­ers are value spe­cific­a­tions. The system evaluates the size when it sends a message with a signature. This happens at the stage spe­cific­a­tion, i.e. at the point at which the message is sent. The result specifies the values for signal at­trib­utes or operation input para­met­ers, depending on who the receiver is. The operation then processes the value further and produces an output parameter.

A special feature is the wildcard parameter. If the message lacks all para­met­ers, the syntax requires an empty string. This symbol indicates that the parameter value is not fixed. Nev­er­the­less, it is valid in terms of the re­cip­i­ent's para­met­ers or at­trib­utes – acting like a wildcard. Wildcard char­ac­ters are place­hold­ers for in­di­vidu­al letters or entire character strings. Many know the asterisk (*) as a place­hold­er. In UML, the hyphen ('-') stands for the wildcard parameter.

Response messages may only have one ex­pres­sion with a maximum of one operand per parameter. If the sender of a reply does not output any values, the message also has no specific values that it sends. Normally, the message models the output para­met­ers of a sender (values that result from an operation) as operands. Without output para­met­ers, the operand must remain empty. In this case, you simply model the wildcard place­hold­er, not the rewind value. If there is an operand, the system evaluates this again in the ap­pear­ance spe­cific­a­tion. The result of the eval­u­ation specifies the values for the para­met­ers ‘out,’ ‘inout,’ and ‘return.’

Fact

=The para­met­ers IN, OUT, and INOUT specify whether an instance takes or returns values. The IN parameter signals that an instance is receiving and pro­cessing values, but is not sending them. The OUT parameter specifies that it does not take values but only outputs them. The INOUT parameter allows both incoming and outgoing values. If you do not define any of these values, the system assumes IN as default.

UML specifies three symbols that determine the recipient of the message as parameter ex­pres­sion. The recipient is the so-called as­sign­ment target of the message. The response message assigns it the response value from the sender's output parameter. These are the stand­ard­ised symbols:

  • Unknown
  • In­ter­ac­tion parameter
  • Attribute

Unknown is an empty parameter and stands for the wildcard. The in­ter­ac­tion parameter is an owned parameter of the in­ter­ac­tion to which it is inherent. This means that the in­ter­ac­tion has the parameter. This has a name. Operation and in­ter­ac­tion para­met­ers have the same type. At­trib­utes can be named without re­stric­tions. They represent the name of a context behaviour. This behaviour de­term­ines either the lifeline to which the message returns or the sur­round­ing in­ter­ac­tion. If the in­ter­ac­tion does not determine any behaviour, it acts as context itself.

Gates are simply points at the end of a message. They belong to type Mes­sageEnd. It marks the sender and recipient of a message. Gates il­lus­trate the flow of in­form­a­tion and show how messages move between two in­ter­ac­tion fragments. More precisely, they represent con­nec­tion points for messages between in­ter­ac­tion benefits and in­ter­ac­tions – and between in­ter­ac­tion operands within and outside of a combined fragment.

The UML sequence diagram re­cog­nises four types of gates. They differ in the fragments of in­ter­ac­tion with which they are as­so­ci­ated:

  • The actual gateway: In­ter­ac­tion benefits point from one diagram to another. The actual gate opens the con­nec­tion at the outer edge of the in­ter­ac­tion benefit for messages from the in­ter­ac­tion to which the in­ter­ac­tion benefit refers. The gate has an as­so­ci­ation to the in­ter­ac­tion benefit and accepts incoming and outgoing messages.
  • The formal gate: For an in­ter­ac­tion to exchange messages with an in­ter­ac­tion benefit, it needs a formal gate. The gate is located on the inside of the frame.
  • Inner Com­bined­Frag­ment gate: Within a combined fragment, there is a gate on the frame. It exchanges messages with message ends from the combined fragment with messages with message ends outside the combined fragment.
  • Outer Com­bined­Frag­ment gate: This gate sits on the outer edge of a combined fragment. It forms the opposite pole to the inner gate.

Gates can have explicit or implicit names that must match in pairs. Actual and formal gates must match, as must inner and outer gates for combined fragments. In addition, the messages must go in the same direction and have the same property values and the same Mes­sage­Sort.

Messages in com­mu­nic­a­tion diagrams play a special role. This diagram type is a simple form of the sequence diagram. Com­mu­nic­a­tion diagrams model how lifelines interact. Unlike sequence diagrams, they focus on the system ar­chi­tec­ture and how it de­term­ines the flow of messages. Although you can show a detailed ar­chi­tec­ture, in­ter­ac­tion fragments such as combined fragments do not use them. As a result, a force element is missing. Instead, number the messages. Sometimes messages can overtake others. The sequence of outgoing messages then differs from the sequence of incoming messages. However, the UML standard advises against such non-se­quen­tial messages in the com­mu­nic­a­tion diagram.

The UML notation for com­mu­nic­a­tion diagrams pre­scribes a simple sequence diagram frame: a rectangle with a pentagon­al label in the head. In the label, the des­ig­na­tion ‘sd’ marks this diagram type. Next to it, note the in­ter­ac­tion name. Messages take a different form here – they connect the rect­an­gu­lar lifelines (UML: object nodes) as simple straight lines (UML: edges).

Above this, note the sequence ex­pres­sion, together with an arrow pointing in the direction of the receiver. The sequence name has the following form: [Integer name][Re­pe­ti­tion]. The integer specifies the hierarchy for nested elements. If one of the integers (for example 1.2.2 and 1.2.3) differs in two messages, the system sends them one after the other. The name, on the other hand, stands for sim­ul­tan­eous broad­casts. The system sends two messages with the sequence names 1.2.3a and 1.2.3b sim­ul­tan­eously because of the identical integer. The re­pe­ti­tion contains either a re­stric­tion that de­term­ines when the message is sent or a value that de­term­ines how often the message is repeated.

Guards

In UML, the guard guards the behaviour of an element. The element must either:

  • Meet a certain condition
  • Not exceed or fall below a certain value
  • Confirm an assertion

A guard is therefore a re­stric­tion. Only if the re­stric­tion is fulfilled can the affected element exert acertain behaviour. There are many different elements that can have this kind of guard – actions, at­trib­utes, behaviour, and others. UML does not prescribe a strict language, but offers OCL, the Object Con­straint Language, as a native option. Boolean variables are also often used.

An in­ter­ac­tion re­stric­tion consists of this kind of Boolean ex­pres­sion. The re­stric­tion serves as a guardian for the operand within a combined fragment. If the value of the con­straint is true, then the sur­round­ing in­ter­ac­tion fragment can start its behaviour. Note the re­stric­tion in square brackets on the lifeline above an execution spe­cific­a­tion. Stand­ard­isa­tion allows combined fragments without re­stric­tion of in­ter­ac­tion. In this case, the system assumes that incoming messages are true.

In­ter­ac­tion fragments in sequence diagrams

When you create a sequence diagram, lifelines and messages are the most important com­pon­ents. UML2 re­com­mends a frame for this diagram type, but this is not ob­lig­at­or­ily. The framework limits a sub-process, the so-called in­ter­ac­tion fragment. All the necessary lifelines and messages are within the frame. It consists of a rectangle with a label in the upper left corner. The indicator for a sequence diagram is the ab­bre­vi­ation 'sd' which is usually in bold. Next to it, the name of the in­ter­ac­tion is entered, as shown in the picture below.

Besides the optical lim­it­a­tion, the frame also serves func­tion­al aspects. When you create multiple sequence diagrams (or other in­ter­ac­tions), the frame separates these rep­res­ent­a­tions. If you want to show that the different in­ter­ac­tion fragments com­mu­nic­ate with each other, model a message (filled arrow) to the frame line. At the top of the screen, the system sends message 5 to the outside. The point where the arrow meets the frame is called the gate. This element has a function within the diagram, but does not have its own notation.

In­ter­ac­tion fragments belong to the nodes in UML. UML specifies the prop­er­ties and tasks of nodes depending on the diagram type in which a par­tic­u­lar node occurs. In general, nodes are model elements within a system or process on which an artifact can be installed. A node connects UML by edges. Edges represent the exchange of in­form­a­tion graph­ic­ally by arrows or by means of simple lines.

In UML, you can create sequence diagrams that contain nested sub-segments. Frames help to display the in­di­vidu­al fragments in an orderly manner.

Sequence diagrams can contain in­ter­ac­tion fragments, in­ter­ac­tion benefits, state variants, event oc­cur­rence spe­cific­a­tion, execution spe­cific­a­tion, and combined fragments.

In­ter­ac­tion

In­ter­ac­tions form a subclass that defines the notation, structure, and behaviour of two meta­classes. These meta­classes are in­ter­ac­tions, and partial de­com­pos­i­tions.

In­ter­ac­tions as meta­classes are in­ter­ac­tion fragments that call or use another in­ter­ac­tion. If your sequence diagram becomes too complex, use this link to make it clearer. The in­ter­ac­tion to which the in­ter­ac­tion refers is shown in the current diagram in a black box view. To uniquely identify the called in­ter­ac­tion, specify the following syntax in the body (field in which instances perform op­er­a­tions):

  • Attribute name (attribute of a lifeline in the in­ter­ac­tion utility that receives the return value)
  • Col­lab­or­a­tion name (iden­ti­fied col­lab­or­a­tion benefits those link in­ter­ac­tions and col­lab­or­a­tions)
  • In­ter­ac­tion name of the called element
  • io-Argument: in/out arguments of in­ter­ac­tion
  • Return value (response of the called in­ter­ac­tion)

You model the in­ter­ac­tion benefit as a rectangle with a pentagon­al label in the upper left corner. Enter the ab­bre­vi­ation 'ref' in this field.

Since in­ter­ac­tion benefits refer to other diagrams, these external factors determine their behaviour. While the linked in­ter­ac­tion has formal gates, the referring in­ter­ac­tion has the actual gate.

Part-de­com­pos­i­tion is the partial, se­quen­tial de­com­pos­i­tion of a lifeline within an in­ter­ac­tion through another in­ter­ac­tion. Using such a de­com­pos­i­tion, you can separate details from each other and look at in­di­vidu­al sub-functions more closely. When messages enter or leave the dis­as­sembled lifeline, they are con­sidered actual gates. These are connected to the formal gates of the de­com­pos­i­tion action. Gates and para­met­ers of both elements must match. As an in­ter­ac­tion benefit, the partial de­com­pos­i­tion also receives the label 'ref' and is defined by the as­so­ci­ated in­ter­ac­tion.

Execution spe­cific­a­tion

The execution spe­cific­a­tion stands for the time on a lifeline in which an object executes a behaviour or passes through an action. You also use it to model the time it takes for an involved object to either send a message or wait for a response. This is because the execution spe­cific­a­tion rep­res­ents an abstract time during runtime. As it applies to the whole diagram anyway, time is not an absolute quantity, but relative. Passive behaviour such as waiting for a response must also be entered as ac­tiv­a­tion in the sequence diagram.

The trace semantics of an execution spe­cific­a­tion is rep­res­en­ted by the simple structure <start,end>. The notation for the execution spe­cific­a­tion allows two forms. Model a long, narrow square with grey filling on the lifeline. Normally, ac­tiv­a­tion in this form does not include a label in the body. Al­tern­at­ively, draw a slightly wider, white-filled rectangle on the lifeline. There, you have space to give the activity bar a label. If an object performs an action during runtime, enter the action name there.

Start and end mark the event oc­cur­rence spe­cific­a­tions. Ac­tiv­a­tion starts with the start event and ends with the closing event. These fragments represent a single moment and exist on a single lifeline. The event oc­cur­rence spe­cific­a­tion rep­res­ents the start or end of an action. The message oc­cur­rence spe­cific­a­tion gives the signal to send and receive a message. Their value therefore always depends on the message or action.

Ac­tiv­a­tion has no separate notation. It exists im­pli­citly at the outer edges of the execution spe­cific­a­tion rectangle. If the execution spe­cific­a­tion performs an atomic action, start and end as­so­ci­ations refer to the same oc­cur­rence spe­cific­a­tion. You can emphasise this with a link line between action and incoming ap­pear­ance spe­cific­a­tion.

Fact

An atomic action appears like a black box. It is an in­di­vis­ible sequence of several simple op­er­a­tions that cannot be observed because they are performed extremely quickly. An atomic action therefore appears to be completed im­me­di­ately.

While other ap­pear­ance spe­cific­a­tions do not require any notation, mark the message ap­pear­ance spe­cific­a­tion de­struc­tion with a large X. It marks the res­ol­u­tion of an object instance at a specific point on the lifeline. The lifeline ends with it. Sub­or­din­ate instances or per­form­ance spe­cific­a­tions at later points in the timeline are then invalid since they no longer exist either after the de­struc­tion of an object.

Sometimes, execution spe­cific­a­tions overlap. For example, if an object sends a message to itself, an execution spe­cific­a­tion sends a message to another instance of this class. Both spe­cific­a­tions are partly on the same lifeline at the same time. In the UML sequence diagram, you represent this cir­cum­stance with over­lap­ping rect­angles.

State invariant

The state variant is a runtime re­stric­tion. The lifeline rep­res­ents an object. During runtime, this object changes its state due to the execution spe­cific­a­tion. The state variant examines the object for its change of state in the execution spe­cific­a­tion – directly before it executes the next ap­pear­ance spe­cific­a­tion. All previous implicit actions within the execution spe­cific­a­tion are then con­sidered executed.

The state variant specifies a re­strict­ive value. If this value is equal to the object state, the track is con­sidered valid. If the object does not meet the re­stric­tion, its track is invalid.

According to the UML sequence diagram notation, the state variant is either in curly brackets on the execution spe­cific­a­tion or you use the rounded rectangle of the state class.

Combined fragments

Combined fragments belong to the in­ter­ac­tion fragments. These fragments are abstract elements of the system. They stand for in­ter­ac­tion units. This means that they are part of an in­ter­ac­tion. On the other hand, they are also small in­ter­ac­tions them­selves. Combined fragments in a sequence diagram determine the behaviour of several in­ter­ac­tion fragments. However, they only form the framework. They are defined by in­ter­ac­tion operators and in­ter­ac­tion operands. Operands contain one or more messages. On the lifeline in front of a combined fragment, a re­stric­tion, also called a guard, watches over the included operand.

As already described, operands are constant or variables that run through a process. Operators influence the behaviour of operands. For example, the Boolean operator ‘OR’ can specify that operand A or operand B is executed (or both). Within a combined fragment, an operand specifies that a specific message is sent under certain con­di­tions. The operator de­term­ines which re­la­tion­ships operands within a fragment have to each other and which re­la­tion­ship they have to the su­per­or­din­ate fragment.

In­ter­ac­tion operators

UML defines 12 in­ter­ac­tion operators

Al­tern­at­ive:

Within the combined fragment with the in­ter­ac­tion operator ‘Al­tern­at­ive,’ a sub­or­din­ate fragment can only send a message if a certain condition is fulfilled. Otherwise, a competing fragment within the frame will send its message. The image above shows an example of a combined fragment with the operator ‘Al­tern­at­ive.’ Use the ab­bre­vi­ation ‘alt’ for the label. You divide the rect­an­gu­lar frame by a ho­ri­zont­al dashed line. The upper area is a condition.

Guard:

The guard checks whether the condition of the operand is fulfilled. If so, the system sends a message in the condition area. If not, it sends a message in the al­tern­at­ive area. An operand within this combined fragment always needs a guard that is judged true to be executed. If the condition operand does not have an explicit guard, an implicit guard is assumed. So this fragment is always an either-or decision.

Option:

This combined fragment is modeled in the sequence diagram like the al­tern­at­ive. It also stands for a decision. However, there is only one operand. The decision is therefore decided on the basis of whether or not the operand should be executed. The operand with a condition must not be empty. Its al­tern­at­ive, on the other hand, is empty. Mark a fragment with the in­ter­ac­tion operator ‘Option’ with the label ‘opt.’

Break:

A combined fragment with the in­ter­ac­tion operator ‘break’ in­ter­rupts the parent fragment. If a lifeline meets the condition of the operand, the system executes the combined fragment, but it ignores the rest of the parent fragment. In order for all lifelines to reach their full life span, you should include each lifeline in the combined fragment. Otherwise, a lifeline may stop in the middle of the process without being properly destroyed. If the break fragment lacks a guard, the decision is non-de­term­in­ist­ic. We therefore recommend using a guard.

Fact

Non-de­term­in­ism is a concept in the­or­et­ic­al computer science to simplify modeling. If the initial value is the same, a system has more than one way of achieving a result. In practice, mainly de­term­in­ist­ic al­gorithms with only one cal­cu­la­tion method are used. However, a non-de­term­in­ist­ic algorithm takes an un­pre­dict­able route in the cal­cu­la­tion, even if you start the system with the same spe­cific­a­tions. Since the algorithm usually produces sig­ni­fic­antly more different results than a de­term­in­ist­ic algorithm, the task at hand should be less complex. Abstract models simplify complex systems. They are therefore suitable to play through different cal­cu­la­tions with the non-de­term­in­ist­ic algorithm

Loop:

A combined fragment with the in­ter­ac­tion operator ‘loop’ repeats its operand. The exact number of passes is de­term­ined by the guard. This monitor can include repeat barriers and Boolean variables. Note the repeat barriers in the frame label as follows: loop (X,Y). The variables X and Y each represent a natural number. X is the minimum number of re­pe­ti­tions (‘min-int’). Y is the maximum number of re­pe­ti­tions (‘max-int’). X must be a non-negative number, Y a non-negative number equal to or greater than the minimum number (i.e. > 0).

You can op­tion­ally note the Boolean variable in the frame body next to the label. It further restricts re­pe­ti­tion. If the condition of the Boolean variable is no longer fulfilled and the minimum number of re­pe­ti­tions is reached, the loop stops. Note the re­stric­tion in square brackets. This re­stric­tion applies to external factors such as input from an actor.

At an ATM, for example, you can enter the correct PIN number three times. If the PIN is incorrect, you will be asked to repeat the entry. In the UML sequence diagram, note the message ‘PIN entry’ and its response ‘Wrong PIN. Try again with the ap­pro­pri­ate arrows. The label has the form Loop (0,2). The Boolean variable is [wrong PIN]. As long as the PIN is wrong, the loop repeats itself twice. If the PIN is correct, the system resolves the loop. If the maximum number of re­pe­ti­tions is exceeded, the loop also loosens, but the process is ter­min­ated as invalid.

Note

Do not specify repeat barriers, the minimum is 0 and the maximum is infinite. Enter only one barrier, minimum and maximum have the same value.

Parallel:

Normally, the position of an arrow on the lifeline in the sequence diagram always pre­scribes a chro­no­lo­gic­al order. In a combined fragment with the in­ter­ac­tion operator parallel, its operands may execute their processes sim­ul­tan­eously. Po­ten­tially, the operands in­ter­twine their process order. However, the given order within the operands is always main­tained. In the UML sequence diagram, model this combined fragment with a con­tinu­ous frame. You separate the different operands optically by dashed lines, similar to the al­tern­at­ive. Enter the ab­bre­vi­ation 'par' in the label (see il­lus­tra­tion under critical region). If operands are to work in parallel on a single lifeline, UML allows an ab­bre­vi­ation: the co-region fulfils exactly this task. To do this, simply enclose the affected event entries in square brackets.

Critical section:

The system uses a critical section to avoid errors that can occur when multiple processes share resources. Within this system area, only one process uses the resource at any one time. In addition, the system pri­or­it­ises the re­spect­ive process. With the label ‘critical’, you define a critical region. This prevents other in­ter­ac­tion operators in a su­per­or­din­ate fragment from having any influence. For example, it blocks nested tracks of a parallel, combined fragment in the sequence diagram.

In the graphic above, a gas supplier hotline accepts several calls in parallel and forwards them sim­ul­tan­eously to hotline employees. If an emergency with suspected gas smell is involved, the system pri­or­it­ises the message and forwards the call to the emergency service via the critical section. The critical section prevents in­form­a­tion streams from the parent fragment from being processed in parallel with the message from the critical section. Only lifelines in the critical section behave like this.

Assertion:

The in­ter­ac­tion operator ‘Assertion’ (also Assurance or Backup) de­term­ines the state of the con­tinu­ation. Sequences within an operand with the label assert are con­sidered valid con­tinu­ations. The claim states that all sequences outside the fragment end in invalid tracks.

Ignore/consider:

A UML sequence diagram rep­res­ents a system part in detail. Some messages you do not need for the view. Others want to take you into account. You use the in­ter­ac­tion operator ‘ignore’ to exclude certain messages. This in­form­a­tion appears on a track in the system, but not in the ignore fragment. The notation pre­scribes a label in this form: ignore {message1,message2}.

Combined fragments with the in­ter­ac­tion operator ‘consider’, on the other hand, consider certain messages in a fragment. All other messages that pass through the fragment are ignored by the system. You can also put messages in brackets to consider: consider {Message3,Message4}.

These two operators have opposite tasks. However, both often occur in nested fragments. For example, modellers often combine assert with ignore (in this form: assert ignore {Msg1, Msg2}) or assert and consider (in this form: assert consider {Msg3, Msg4}).

Negative:

To indicate a system error, the in­ter­ac­tion operator ‘negative’ is used, meaning the combined fragment contains invalid traces. The operator is used, for example, when you display a log-in procedure using a sequence diagram. Model the lifeline of an actor on the way to time-out, and frame this error message with the negative fragment. Due to the explicit modelling of invalid tracks in the negative combined fragment, all other fragments are con­sidered positive. Your tracks are valid.

Strict order:

Within a combined fragment, it may be important to maintain a strict order. The strict label imposes strict se­quen­cing on its operands. This applies to the first level of the fragment. Operands in further nested fragments are subject to their own order.

Combined fragments with the in­ter­ac­tion operator ‘sequence’ represent a weak order. The behaviour between the operands in the fragment in­flu­ences trace prop­er­ties instead of the in­ter­ac­tion operators. A weak se­quen­cing can therefore act like a parallel fragment. This happens when operands par­ti­cip­ate on different lifelines. In turn, weak se­quen­cing turns into a strict order when its operands appear on the same lifeline. The label is ‘seq’.

Tracks with the following prop­er­ties define weak se­quen­cing:

  1. Event spe­cific­a­tions within an operand keep their order
  1. Event spe­cific­a­tions that act on different lifelines and do not occur within the same operand occur in any order
  2. If the event spe­cific­a­tions act on the same lifeline, but in different operands, their place on the lifeline dictates their order (the first operand comes before the second operand)

Con­tinu­ation:

The con­tinu­ation is hardly a fragment in its own right. Only in the combined fragments al­tern­at­ive and weak sequence does it get its own semantics. This pre­scribes the same form for the con­tinu­ation as for states: a rectangle with rounded corners. In contrast to the condition, a con­tinu­ation op­tion­ally covers several lifelines.

Your task also changes depending on how you arrange the con­tinu­ation in the sequence diagram. If the con­tinu­ation is at the beginning of your in­ter­ac­tion diagram, you use it to model the behaviour of the con­tinu­ation. If the con­tinu­ation is at the end of your in­ter­ac­tion fragment, it forwards the process. If you name your con­tinu­ation (as in the example: notOK), the next fragment on the lifeline must have a con­tinu­ation with the same name (notOK) or it may not model a con­tinu­ation. If the con­tinu­ation is in the fragment alone, this cor­res­ponds to a con­tinu­ation at the end of the fragment.

Con­clu­sion

If you want to show ap­plic­a­tion examples in detail or check the logic of a system, create a sequence diagram. The notation allows you to model the flow of messages over the entire lifetime of an object. Even complex op­er­a­tions are clearly rep­res­en­ted with the help of nested in­ter­ac­tion fragments. The sequence diagram is one of the most used UML behaviour diagrams.

Go to Main Menu