Arguments, parameters, and return values specified on a Message in a Sequence diagram can be parsed and new Operations can be created. Parsing and mapping Message names to real model elements (operations, parameters, etc.) allows for easy transition from prototype Sequence diagrams to complete Sequence diagrams representing actual Interactions between system parts.
Message name parsing
On a Message name area on a diagram pane, you can type the name of a new Operation together with arguments, parameters, and return value. After you click on the button near the Message name, the new Operation will be created, together with its specifications.
If any Message name syntax errors are found, users are warned and given suggestions for fixing these mistakes. The Message Parsing notification message opens, showing the concrete error.
Image Modified
In the preceding example, you can see that the following appears on the Message name:
getUserAddress(city=”Allen”, street=”700 Central Expy S”, No=”110”). After you click the Create New Operation (this message button Image Modified), the new getUserAddress Operation will be created. The following Message arguments will be created - Allen, 700 Central Expy S, and 110, together with the corresponding parameters - city, street, No.
To create a new operation from the diagram pane
Create a call Message (asynchCall or synchCall) between two Lifelines.
Note
The Lifeline that the call Message is connected to must have a type specified.The preceding figure shows that the Address type is assigned to the second Lifeline.
On the diagram pane, on the message, type the message name according to the syntax rules.
After you have typed the Message name, exit the edit mode by clicking on the diagram pane.
Select the Message label again. The Create New Operation according to this message button Image Modified is displayed next to the Message name.
Click the Create New Operation according to this message button Image Modified. A new Operation is created and represented in the message Specification window, the Signature (operation) property cell .
Note
Note that a new Operation is created only after you click the Create New Operation according to this message button Image Modified. If you do not click this button, the Message label will be treated as a Message name.
The following table describes Message name samples and parsing results:
Purpose
Message name typed on the diagram pane
Action after typing on the message label
Result
Create a new Operation
login ()
Click the Create New Operation according to this message button Image Modified.
The new operation is created: login ()
The Operation is referenced in the Message Specification window, the Signature (operation) property cell.
For the Lifeline type, the login operation is created.
Note
After click on the Create New Operation according to this message button Image Modified, a new Operation is always created. A new Operation is created even if an Operation with the same name already exists.
Create a new Operation with an argument
login (“John”)
Click the Create New Operation according to this message button Image Modified.
The new operation is created: login (unnamed1=”John”)
The Operation is referenced in the Message Specification window, the Signature (operation) property cell.
In the message Specification window > the Arguments property group, the following argument is created: John.
For the Lifeline type, the login Operation is created.
The login Operation’s parameter is created and synchronized with the message argument.
Note
Different kinds of arguments are supported. For the following arguments the following value specifications are created:
John - Opaque Expression
12345 - Literal Integer
True - Literal Boolean
“John” - Literal String (always when quotation-marks are used).
Create a new Operation with a parameter and an argument
login (username=”John”)
Click the Create New Operation according to this message button Image Modified.
The new operation is created: login (username=”John”)
The Operation is referenced in the Message Specification window, the Signature (operation) property cell.
In the Message Specification window > the Arguments property group, the following argument is created: John.
For the Lifeline type, the login operation is created.
The login operation’s parameter is created and synchronized with the Message argument.
Create a new Operation with a return parameter
login () : true
Click the Create New Operation according to this message button Image Modified.
The new operation is created: login () : true
The Operation is listed in the Message Specification window, the Signature (operation) property cell.
In the Message Specification window > the Arguments property group the following argument is created: true.
For the classifier assigned to the Lifeline, the login Operation is created, together with the parameter.
The login Operation’s parameter with the return direction is created. The Operation’s parameter is synchronized with the Message argument.
Create a new Operation for the Message together with a reply Message
status = login ()
Click the Create New Operation according to this message button Image Modified.
The new operation is created: status = login ()
The Operation is listed in the message Specification window, the Signature (operation) property cell.
In the Message Specification window > the Reply message property cell, the replay Message is created. (The Replay message property cell is displayed in Expert mode only.)
3. The status argument is created in the replay Message.
Create a new argument for the Message
Note
If this is valid, the argument is added straight from the Message label for the already-existing Operation.
Before was:
login (username=John)
Add the argument 1282:
login (username=John, 1284)
Exit the Message label edit mode by clicking the diagram pane.
A new argument is created and the Message is highlighted with yellow color; that is, the validation warning appears informing you that a parameter is missing and the Message argument is not synchronized with the operation parameter.
Image Modified
To resolve the validation warning:
Click the Message. The Message smart manipulator toolbar displays.
Click the button Image Modified to synchronize the Message argument with the Operation parameter.
Update the argument
Before was:
login (John)
Now change the argument to:
login (Joseph)
Exit the message label edit mode by clicking the diagram pane.
The argument is updated.
Anchor
incorrect_synax
incorrect_synax
Notification message about incorrect syntax
If the Message syntax is incorrect, you will receive the following notification message at the bottom right corner of the MagicDraw window.
Image Modified
In the first line of the Message Parsing notification message, you will see an incorrect message name. In the example, the incorrect Message name is getUser Address(city=). Due to the incorrect Message name, parsing cannot be executed and a new Operation cannot be created. In the second paragraph of the Message Parsing notification message, you will see the explanation of which syntax is expected. Next, you can see an example of the correct Message syntax.