Sequence diagram comparison options
Specification sequence diagrams show only one specific thread from the mind of the designer. Therefore, certain instances and messages will be missing. However, execution (animated) sequence diagrams reflect the full collaboration between objects. This is why the simple comparison between specification and execution sequence diagrams always fails. IBM® Engineering Systems Design Rhapsody® provides various options that enable you to compensate for some of the necessary differences between the two kinds of diagrams when doing a sequence comparison.
Select Options in the Sequence Diagrams Comparison window to open the Sequence Diagram Comparison options window.
General comparison options
Use the following fields on the General tab to specify whether to use synchronization and to save or upload your option settings:
- Synchronization specifies whether to ignore the arrival times of messages.
- Save saves your option settings to a file that you can reuse.
- Load loads your option file.
Sometimes the order of arriving messages is insignificant. The Synchronization option enables you to ignore the arrival times of messages and consider only the order in which they are sent.
In the resulting comparison display, equivalent messages are vertically synchronized in the adjacent window panes. This helps you to locate corresponding messages in both diagrams.
To enable or disable the synchronization option, select or clear the Synchronization box in the General tab.
You can save your options settings to a file and then reload them for subsequent message comparisons.
To save the settings:
- Click the Save button on the General tab.
- The Save As window opens. The default name for
the options file is composed of the first words of the titles of each
of the diagrams being compared separated by an underscore:
<SD2>_<SD1>.sdo
The file extension
.sdo
stands for Sequence Diagram Options. If wanted, edit the path and default name for the options file. - Click OK.
To reload your option settings:
- In the General tab, click Load. The Open window is displayed.
- Select the
.sdo
file that contains your option settings. - Click Open.
The sequence comparison options are restored to the settings last saved in the file.
Message selection
The Message Selection tab, shown in the following figure, enables you to select which messages to include and whether to include arguments in the comparison.
On this Message Selection tab, the word "Ignore" is the default setting for the Arguments column for all messages. This means that, by default, argument comparison is ignored for messages.
Using this tab, you can:
- Exclude a message from the comparison (see Excluding a message from the comparison)
- Compare arguments (see Comparing arguments)
Excluding a message from the comparison
Specification sequence diagrams typically include information that is essential to a particular use case or scenario. In many cases, they exclude the initialization phase messages, whereas execution sequence diagrams include all messages. Therefore, it might be necessary ignore certain messages when doing a comparison, such as constructors. Ignored messages are inaccessible in the resulting comparison window.
To exclude a message from the comparison:
- Select the message to exclude.
- Click Edit. The Edit Message Compare Options window opens.
- Click the Ignore box to exclude the message from the comparison.
- The three radio buttons, allow you to specify the way to treat Arguments associated with the selected message.
- Click OK.
Comparing arguments
There are two options for determining whether messages are identical: the first is to compare the message names and all arguments, the second is to compare only the message names. The latter option is more useful because sequence diagrams show four different kinds of arguments:
- Unspecified arguments
- Actual values
- Formal names
- Both names and values
In specification sequence diagrams, you might not always provide complete information about message arguments. Because execution sequence diagrams record what the system actually does, they always show both argument values and names. Therefore, the message comparison ideally does not use arguments but rather focus primarily on message names.
When two messages are named identically, you can compare their arguments.
For
example, consider messages called evDigitDialed(Digit)
.
They would be equivalent if you compared only their argument names
(Digit
). However, if you compared their values (EvDigitDialed(Digit=0)
, EvDigitDialed(Digit=1)
,
and so on), their argument values would not be equivalent.
Argument comparison occurs in the following steps:
- Find each argument.
- Find the argument name and value.
- Determine whether to use the name, the value, or both for the comparison.
To specify whether to use argument names or values:
- In the Message Selection tab, select a message and click Edit. The Edit Message Compare Options window opens.
- Select one of the following options:
- Compare Names Only compares argument names, but ignore their values.
- Compare Names and Values compares both argument
names and values.
These are commonly used settings:
Specification sequence diagram | Execution sequence diagram | Value |
---|---|---|
Message() | Message(Arg = 1) | Ignore Arguments |
Message(Arg) | Message(Arg = 1) | Compare Names Only |
Message(1) | Message(Arg = 1) | Compare Names and Values |
- Click OK.
Depending on your selections, the following labels are displayed in the Arguments column on the Message Selection tab:- Disable means messages for which arguments are to be ignored
- Name means messages for which argument names are to be compared, but not the argument values
- Value means messages for which both argument names and values are to be compared
Instance groups
In specification sequence diagrams, all messages sent by the environment come from specific objects. In execution sequence diagrams, however, these messages could potentially come from you interacting with the animation. This difference can impair the comparison.
In general, requiring a complete object match between execution and specification sequence diagrams is too rigorous a requirement. The solution is to associate objects in one sequence diagram with other objects in the other sequence diagram. Messages can then match if their source and target objects are associated in both sequence diagrams.
To associate objects with each other you create object groups. Object groups are, in essence, instance abstractions that bridge the gap between high-level use cases and actual implementation, or between black-box and white-box scenarios. Using object groups, you can then compare objects that do not have the same name, or compare one object to several other objects.
To view object groups, select the Instance Groups tab in the Sequence Diagram Comparison options window. The Instance Groups tab, shown in the following figure, displays a list of the existing object groups in the model. There is one object group for each object, which is, by default, the only member of its own group.
.
The objects that belong to the group are displayed in the Objects groups list in the window. This means that the objects listed for SD1 are considered logically the same as those listed for SD2.
The Instance Groups tab enables you to perform the following operations:
- Add creates an object group
- Delete deletes an object group
- Edit modifies an existing object group
- Set to Default resets an object group
- Delete All deletes all object groups
To create an instance group:
- On the Instance Groups tab,
click Add. The Edit Object Group window opens.
The default name for new object groups is
ClassBuffn
, where n is an integer starting with 1. - If wanted, edit the name of the new object group.
- To add objects to the group, move one or more unused objects from either of the boxes on the right to the corresponding box on the left.
- Click OK.
To delete an existing object group:
- On the Instance Groups tab, select the object group you want to delete.
- Click Delete.
- Click OK.
Any objects that belonged to the deleted group are now unused and available to be assigned to another object group.
To delete all instance groups:
- On the Instance Groups tab, click Delete All.
- Click OK.
All objects are now unused and available to be assigned to a new object group.
If you want to associate different objects than the ones shown, either move one or more of the objects to a different object group or create a group. In either case, you first need to remove the object you are moving from the group it is currently in, because an object can only belong to one group at a time.
To remove an object from a group:
- On the Instance Groups tab, select an object group.
- Click Edit. The Edit Object group window opens.
The name of the selected object group is displayed in the window. The name box is unavailable because you cannot edit it here.
The Edit Object Group window contains four boxes. The two on the left show which objects in SD1 will be associated with which objects in SD2. The two boxes on the right show which objects in each diagram are currently not assigned to any group, and are therefore available to be assigned to a group. - Select an object in one of the boxes on the left and click the right arrow button.
To add an object to the group:
- Select an object in one of the boxes on the right, and move it with the left-arrows button.
- Click OK. The selected object in one diagram is now available to be added to another group.
- On the Instance Groups tab, select the new group for the object and click Edit.
- Select the object in the Unused Objects in SD<number> box and click the left-arrows key to add it to the group.
- Select the object in the To Objects in SD<number> box and click the right-arrows button to remove it from the group.
- Click OK.
To set all object groups back to the default of one group per object, click Set to Default on the Instance Groups tab. An object group is added for each object with the same object in SD1 and SD2 belonging to the group.
Message groups
In specification sequence diagrams, you often must assume how the message queue works to determine the sequence of messages. It is highly likely that in specification sequence diagrams the order of messages will be different from the actual one specified in the statechart. An incorrect ordering assumption can result in large mismatch.
M1
sent by an
instance A1
after a message M2
sent
by an instance A2
could match the same message sent
before M2
:There can also be cases where two or more messages are to be sent at the same time, but the order is not important. Message groups enable you to specify groups of messages for which ordering is not important. There is a match if any message in the group occurs in any order.
The Message Groups tab, shown in the following example, enables you to create, modify, and delete message groups.