Sequence Diagram
Overview
Sequence diagrams can be used to visualize the flow of mutual processing between objects.
This page explains the operations for using sequence diagrams in the following order.
- Place sequence diagram
- Define your lifeline
- Define the message
- Define a compound fragment
- Define interaction usage
We also provide the following features to assist users in their modeling:
These will also be explained in turn.
- Validate the model
- Set display content
Place the sequence diagram
To place a sequence diagram, follow these steps:
- Select the package in the model navigator and click [Add Model] > [Sequence Diagram] in the context menu.
- The sequence diagram is placed as a child element of the selected package.
Define lifeline
To define a lifeline, follow these steps:
- Select an existing class in the model navigator and drag and drop it onto the sequence diagram.
- A new lifeline with the selected class as its type is created in the displayed sequence diagram.
You can add the following elements displayed in the toolbox to the sequence diagram.
Icon | Name |
---|---|
Lifeline | |
Composite fragment | |
Use of Interaction | |
Interaction Note | |
Destruction |
Define an untyped lifeline
You can create a lifeline without a type by dragging and dropping [Lifeline] from the toolbox onto the sequence diagram.
To change the lifeline type, select the lifeline on the sequence diagram and click [Change lifeline type] on the context menu.
Lifeline types that can be set
A lifeline type can have the following elements:
Icon | Name |
---|---|
Class | |
Interface | |
Component | |
Actor | |
Block |
Define the message
To define a message, follow these steps:
- In the sequence diagram, when you hover your mouse over a lifeline, a black triangle icon will appear.
- Drag and drop the displayed icon towards the target lifeline.
- When the finder appears, select the operation corresponding to the message and press the [OK] button.
- A synchronization message is created for the target lifeline.
You can add the following elements displayed in the sub toolbox to the sequence diagram.
Icon | Name |
---|---|
Synchronized message | |
Asynchronous Message | |
Reply Message | |
CreateMessage | |
Discard message |
When adding these messages, select the type of message you want to add in the sub toolbox and then add the message.
If you enter a message operation as text on a sequence diagram, the text will be analyzed according to the notation format of the message operation.
Of course, if you change each field value, it will be reflected in the text on the diagram.
Correspondence between message text representation format and each field value
Messages are displayed and parsed as text according to the following format:
- For request messages (other than response messages)
<Request message> ::= <Message name> ['('[<List of arguments>] ')'] [':'<Return value type>]
- supplement
<List of arguments>
is displayed in the following format.<List of arguments> ::= <Arguments> [','<Arguments>]*
<Argument> ::= [<Argument name> '='] <Argument value> | '-'
- Example
Message name:Drive
Argument 1 name:m
, value:100
Argument 2 name:s
, value:200
Return type:boolean
In this case, the following text will be displayed.
Drive(m=100, s=200) : boolean
- Note
<return type>
is ignored when setting.
- supplement
- For response messages
<Response message> ::= [<Return value variable name> '='] <Message name>['(' [<List of arguments>] ')'] [':' <Return value>]
- supplement
<List of arguments>
is displayed in the following format.<List of arguments> ::= <Arguments> [','<Arguments>]*
<Argument> ::= [<Argument variable name> '='] <Argument name> [':' <Argument value>]
- Example
Return value variable name:return_value
, return value:true
Message name:Drive
Argument 1 variable name:miles
, argument name:m
, value:200
Argument 2 variable name:speed
, argument name:s
, value:100
In this case, the following text will be displayed.
return_value=Drive(miles=m:200, speed:s=100) : true
- supplement
To change the action for a message, select the message and click Change Message Type on the context menu.
Define composite fragment
To define a composite fragment, follow these steps:
- Select the composite fragment in the toolbox and drag and drop it onto the sequence diagram.
- Double-click the top left of the added composite fragment to display a drop-down list of types and select the type of composite fragment to add.
Composite fragments can be of the following types:
Change Shape Type | Meaning |
---|---|
alt | Alternative |
opt | Option |
loop | Loop |
par | Parallel |
break | Break |
neg | negation |
strict | strict |
seq | seq |
ignore | ignore |
consider | consider |
assert | Assert |
Define interaction usage
To define interaction usage, follow these steps:
- Select Use Interaction in the toolbox and drag and drop it onto the sequence diagram.
- Select the use of the added interaction and associate the sequence diagram to be referenced with [Associate Interaction] from the context menu.
To jump to the sequence diagram associated with an interaction usage, select the interaction usage and click Show Associated Interactions in the context menu.
Validate the model
The contents verified by the sequence diagram are as follows.
- Is the operation associated with the message available for the destination lifeline type?
For example, you can detect inconsistencies between the operation associated with a message and the type of the destination lifeline as a result of the following changes:
- Specify the operation defined in the inheritance source class of the class that is the type of the destination lifeline as the operation associated with the message.
- Delete the inheritance relationship of the class that is the type of the destination lifeline using a class diagram, etc.
To validate your model, follow these steps:
- Run UML > Validation > Check Consistency from the ribbon.
- If an inconsistency is detected in the messages placed in the sequence diagram, an error will be displayed.
Click the [Home] > [Model] > [Check Error] button on the ribbon to perform validation on all models in addition to the standard validation.
Set display content
You can display only the information of interest in sequence diagrams without changing the model.
To set the display contents of the arguments corresponding to the request message, follow the steps below.
- Display the sequence diagram whose display you want to switch.
- Select the argument checkbox in the Request Message group on the UML Diagram tab in the Inspector.
You can switch the display of the following elements in sequence diagrams.
Category | Element |
---|---|
Request message | Arguments |
Argument name | |
Return type | |
Response message | Argument |
Argument value | |
Argument assignment variables | |
Return value | |
Return value variable |
Restrictions
- State invariant expressions and duration constraints cannot be defined.
- It is not possible to connect messages from frames.
- Cannot connect messages to interaction usage.
- Copying and pasting of elements is not possible.
- The order of messages in a sequence (commonly called GeneralOrdering) is represented only by the Y coordinate on the diagram. If you use the difference comparison function, you cannot check the differences as a model.
- Stereotypes are not represented on sequence diagrams.