Sequence diagram enhancements in IBM Rational Software Architect and IBM Rational Software Modeler

Rational Software Architect for WebSphere Software, Rational Software Architect Standard Edition, and Rational Software Modeler 7.0.5

This article describes enhancements to the sequence diagram editor in Version 7.0.5 of IBM® Rational® Software Architect for WebSphere® Software, IBM® Rational® Software Architect Standard Edition, and IBM® Rational® Software Modeler, which make it easier to edit and modify diagrams. In addition, the introduction of message sets and support for classifier-inherited operations give you better editing control of messages and lifelines.

Darren Coffin (dcoffin@ca.ibm.com), Software Verification Developer, IBM

Darren Coffin has been working in software verification on modeling tools with IBM Rational since 1999. He has worked extensively on testing a broad number of modeling features and diagrams. He is a graduate of Trent University, with a B.Sc. in Computer Studies and Environmental Resource Studies.



Michael Hanner (mhanner@ibm.com), Software Development Manager, IBM

Michael Hanner joined IBM in 2002 with more than 15 years of experience in the software industry. He is the Rational Software Modeler product development lead. His responsibilities include the UML and domain modeling platforms, as well as the modeling for open source projects, such as EMF, GEF, GMF, and UML.



Tao Weng (tweng@ca.ibm.com), Software Developer, IBM

Tao Weng has been working for the IBM Rational modeling team since 2004 and is known for his expertise in model merge and UML diagrams. He is the key developer of sequence diagrams and in charge of other features within the product.



21 April 2009

Also available in Chinese Spanish

This article provides information regarding the enhancements made to the sequence diagram editor in Version 7.0.5 of IBM® Rational® Software Architect for WebSphere® Software, IBM® Rational® Software Architect Standard Edition, and IBM® Rational® Software Modeler (hereafter referred to as "these Rational products." The key enhancements are the ability to move and reorder messages and lifelines. This article also explains an easy method to set classifier-inherited operations for messages.

Without the ability to reorder messages and lifelines within the sequence diagram editor, you would be forced to repetitively redraw (delete and recreate) existing sequence diagram elements to simulate reorder operations. For example, to reorder an existing message1 below message2, you would need to first delete message1 and then recreate the same message1 below message2. A similar problem would occur with lifelines.

The message and lifeline reordering operation provides the solution. The sequence diagram editor now has two modes for selection: The default is move mode, and the other is reorder mode. Dragging and dropping selected messages is treated differently in each mode. The reorder operation changes the order of sequence diagram elements (these are semantic changes); whereas, the move operation changes only the amount of space between sequence diagram elements (semantically, the sequence diagram remains the same).

The ability to set classifier-inherited operations for messages is now easier and more convenient, too. If the target lifeline represents a classifier, the sequence diagram editor now allows you to select either classifier-owned or inherited operations as the operation for the message. Previous versions of the sequence diagram editor allow you only to select classifier-owned operations. If you wanted to select classifier-inherited operations, you needed to do so from the Advanced Property page of a message event, which is extremely complicated and difficult to use. Selecting classifier-inherited operations for messages is a more common workflow.

Message reordering

The ability to change the order in which messages appear on a sequence diagram has been enhanced, making it easier to get them into the desired order. All elements within the diagram will be considered during a reorder operation, not just those visible on the screen.

Message set

A message set is a group of messages that need to be treated together as one atomic unit during a reorder operation. What actually constitutes a valid message set is defined by message set collection rules. Message set collection rules are context-sensitive. Based on your selection, different message set collection rules will be triggered and different message sets will be found.

Reordering existing message sets

In the context of reordering, it often makes sense to reorder the whole message set as a single unit so that you preserve the ordering within the set. To change the order of a message set, you follow these steps:

  1. Select the message set. Right-click on the first message in the set and select Message Set/Reorder as Figure 1 shows (alternatively, you can use Alt+left-click on the first message in the message set). The message set will be highlighted in blue for preview purposes. You see what is going to be reordered, and the sequence diagram editor is now in reorder mode.
Figure 1. Selecting a message set for reorder mode
Selected element highlighted in blue
  1. Drag the message where you want it to be. Left-click on the selected message set and drag it up or down the sequence diagram. Notice that a dotted line guide shows you exactly where the message set will be dropped (see Figure 2).
Figure 2. Dotted line guide appears while you are dragging message set
line guides highlighted in blue

After the reorder, the message numbering will be updated to reflect the new order (Figure 3). Tip: Be sure to deselect the elements to exit reorder mode.

Figure 3. Result of reordering a message set
Order element moved down

In special circumstances, other events will be automatically handled by the toolset. If a create message is reordered, the starting point of the created lifeline will be moved to match the new location of the created message. If a destroy message is reordered, the ending point of the destroyed lifeline will be moved to match the new location of the destroy message.

Combined fragments

With the reorder operation, you can reorder message sets into, out of, and between combined fragments. When reordering a message set into a combined fragment, the tool first checks whether the target combined fragment is a valid container of the message set. The combined fragment is considered valid if all of the message set's covered lifelines are also covered by the combined fragment. If it is not valid, the tool prevents you from completing the operation.

  1. Select the message set. Right-click on the first message in the set and select Message Set/Reorder (alternatively, you can use Alt+left-click on the first message in the message set). The message set will be highlighted in blue for preview purposes. You can see what is going to be reordered, and the sequence diagram editor is now in reorder mode.
  2. Drag the message set into an invalid target combined fragment. Left-click and drag the selected message into a combined fragment. If the combined fragment is not a valid container of the selected message set, no feedback line will appear.
  3. Drag the message set into a valid target combined fragment. Left-click and drag the selected message into a combined fragment. If the combined fragment is a valid container of the selected message set, a dotted line will appear, showing you exactly where the message will be dropped (Figure 4).
Figure 4. Dotted line guide during drag/drop into a container
Line indicates movement direction
  1. Complete the drag operation. The message set is then reordered into the combined fragment. Figure 5 shows the result.
Figure 5. Result of reorder into a container
Reorder result

Follow similar steps to reorder a message set from a combined fragment into an interaction and to reorder a message set between combined fragments.

Individual messages

Sometimes, you want to reorder a particular message within a message set instead of reordering the whole message set. In order to complete that, they need to first break up the message from the message set.

Synchronous message

To break up a synchronous message from a given message set, follow these steps:

  1. Select the message. Right-click the return part of the synchronous message and select Message Set/Reorder (alternatively, you can use Alt+left-click on the return message). The return message will be highlighted in blue for preview purposes.
Figure 6. Selecting the return part of synchronous message for reorder mode
Blue arrow shows new order path
  1. Drag the message. Left-click and drag the return message up until it is the next one above the send message of the same synchronous message.
Figure 7. Dotted line guide during drag/drop of return message
Blue line shows path
  1. Check the result. Complete the drag operation. The synchronous message gets separated from the message set and does not contain any nested messages.
Figure 8. Result of breaking up a synchronous message set
Purchase no longer has nested messages

Asynchronous message

To break up an asynchronous message from a given message set, follow these steps:

  1. Select the behavior execution specification that the message belongs to. Left-click on the behavior execution specification.
Figure 9. Selecting behavior execution specification to resize
Border around selected element
  1. Drag one of the handles of the border. Left-click and drag the behavior execution specification's handles to resize it until there is no nested message.
Figure 10. Behavior execution specification resize feedback
Element still selected

The asynchronous message is broken up from the message set. As Figure 11 illustrates, it shows the purchase element without any nested messages.

Figure 11. Result of breaking up an asynchronous message set
Purchase separated from AskPrice and Order

After breaking up the message from the message set, the message can then be reordered to the target location:

  1. Select the message set. Right-click on the send part of the message and select Message Set/Reorder (alternatively, you can use Alt+left-click on the send message). The message will be highlighted in blue for preview purposes. The editor is now in reorder mode (see Figure 12).
Figure 12. Selecting a single message for reorder mode
Outlined rectangle shows new order
  1. Drag the element to the new location. Left-click and drag the selected message up or down the sequence diagram. Notice that a dotted line guide shows exactly where the message will be dropped.
Figure 13. Dotted line guide during drag/drop of a single message
Shows dotted line
  1. Check the result. Complete the drag operation. The message is moved to the new location, and all of the messages are renumbered appropriately.
Figure 14. Result of reordering a single message
New location

Reorder validation

Certain reorder operations may cause the target model to become invalid if they violate the UML2 specification. The toolset prevents invalid models from being created by validating the results of each reorder request before it is performed. If the result is an invalid model, the tool will abort the operation and display an error message.

Figure 15 shows an example.

Figure 15. User attempts an invalid reorder
X shows problem

The logout message is a destroy message. After the logout message, the customer's session with onlineStore is terminated. If you try to reorder the purchase message to place it after the logout message, this is not correct because the onlineStore no longer exists at that point. In such a situation, a Live Validation error message (Figure 16) will appear, saying "The requested action violates the integrity of the model," and you will not be able to complete the action.

Figure 16. Live Validation error message
Error message that also gives the reason

Message moving

Moving a message without changing its order within the other messages on the diagram has been simplified. By default, the sequence diagram editor is in move mode. Simply click and drag a message up or down, and other messages on the diagram will be shifted out of the way. This is useful to provide space for Note elements or to improve the aesthetic layout of the messages. The drag-and-drop action will change the amount of space between the messages but preserve the order of the messages.

Lifeline reordering

Similar to message reordering, the lifeline reordering operation enables you to change the order of lifelines on the diagram. You can reorder a single lifeline from one location to another. Changing the order of lifelines does not change the semantics of the diagram, but it often improves the clarity or aesthetics of the diagram. For example, the lifeline of a wrapper class should probably be right next to the lifeline of the wrapped class. The tool also allows multiple lifelines to be selected together and reordered in one action.

Single lifeline reorder operation

  1. Select a single lifeline. Right-click, select the Reorder Lifelines command from the drop-down menu (alternatively, you can use Alt+left-click on the lifeline).

The selected lifeline will be highlighted in blue to provide feedback that the sequence diagram editor is now in reorder mode, indicating what is going to be reordered (see Figure 17).

Figure 17. Selecting a single lifeline for reorder mode
customer:Customer highlighted
  1. Drag the lifelines to the new location. Left-click and drag the selected lifelines to the left or right. A dotted blue line will appear to indicate the insertion point for the selected lifelines. The blue line will appear only if the target insertion point is valid for the selected lifeline.
Figure 18. Dotted line guide during drag/drop of a single lifeline
  1. Check the result. Complete the drag operation.

The selected lifeline is reordered to the target location as Figure 19 shows.

Figure 19. Result of reordering a single lifeline
Shows new location

Multiple lifelines reordering

  1. Select multiple lifelines. Left-click on a lifeline and then use Ctrl+left-click to select additional lifelines. Right-click on the selected lifelines, select Reorder Lifelines from the drop-down menu (alternatively, you can use Alt+Shift+left-click on multiple lifelines).

The selected lifelines will be highlighted in blue to indicate that the sequence diagram editor is now in reorder mode and to show what is going to be reordered.

Figure 20. Selecting multiple lifelines
Two lifelines highlighted
  1. Drag the lifelines. Left-click and drag the selected lifelines to the left or right.

A dotted blue line will indicate the insertion point for the selected lifelines. The blue line will appear only if the target insertion point is valid for the selected lifelines.

Figure 21. Dotted line guide during drag/drop of multiple lifelines
Dotted line shows insertion point
  1. Check the result. Complete the drag operation.

As Figure 22 shows, the selected lifelines are reordered to the target location.

Figure 22. Result of reorder of multiple lifelines
Diagram shows the new order

Lifeline moving

Similar to message moving, the lifeline moving operation enables you to change the amount of space between lifelines. This will create space for long message signatures and for inserting notes, comments, or constraints. By default, the sequence diagram editor is in move mode. Simply left-click and drag a lifeline left or right, and other lifelines on the diagram will be shifted out of the way.

Set classifier-inherited operations

Setting inherited operations for messages

Another enhancement made in these Rational software products is the ability to easily set classifier-inherited operations for messages. If the target lifeline represents a classifier, the sequence diagram editor now enables you to select either classifier-owned or inherited operations as the operation for the message.

In order to find qualified inherited operations, the target classifier's generalization hierarchy (based on generalization relationships) will be traversed. If the target classifier is of type class (or a subtype of class), the realization relationship hierarchy will also be traversed. Also, the provided interfaces of all class-owned ports will be considered and their operations will be added. If the target classifier is of type component, all operations from the component's provided interfaces will also be traversed, in addition to the generalization and realization hierarchies.

Figure 23. Creating an operation from the sequence diagram
Enter Operation name and owner dialog

As you can see from Figure 23, when creating a new operation from the sequence diagram, there is a drop-down menu in the Create New Operation dialog. It lists all of the available owners of the new operation.

Figure 24. Selecting an operation on the sequence diagram
List of available owners

When you double-click on a message operation signature on a sequence diagram, a list of available operations will display. That list contains the owned and inherited operations of the target classifier.

Summary

The enhancements described in this article improve the usability of the sequence diagram, thus making it easier for you to edit and modify your diagrams. Through the use of reordering single messages or entire message sets, you can change the order of the messages on the diagram in a very customizable way. Handling of classifier-inherited operations is also easier.

Resources

Learn

  • Subscribe to the IBM developerWorks newsletter, a weekly update on the best of developerWorks tutorials, articles, downloads, community activities, webcasts and events.
  • Subscribe to the Rational Edge newsletter for articles on the concepts behind effective software development.

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into Rational software on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=382771
ArticleTitle=Sequence diagram enhancements in IBM Rational Software Architect and IBM Rational Software Modeler
publish-date=04212009