Skip to main content

Web services programming tips and tricks: UML sequence diagramming with style

Sequence diagramming tips

Scott W. Ambler (scott_ambler@ca.ibm.com), Practice Leader, Agile Development, Rational Methods Group, IBM
Scott W. Ambler is President of Ronin International, a consulting firm specializing in object-oriented software process mentoring, architectural modeling, and Enterprise JavaBeans (EJB) development. He has authored or co-authored several books about object-oriented development, including the recently released The Object Primer 2nd Edition, which covers, in detail, the subjects summarized in this article. He can be reached at scott.ambler@ronin-intl.com and at his Web site at www.ambysoft.com.

Summary:  Try these tips for creating effective UML sequence diagrams. This article was adapted from Chapter 6 of The Object Primer 2nd Edition.

Date:  01 Feb 2001
Level:  Introductory
Activity:  770 views

There are several ways that you can improve the quality and effectiveness of your UML sequence diagrams. These include:

Verify decisions

When I developed the sequence diagram of Figure 1, I made several decisions that could potentially affect my other models. For example, as I modeled Step 10, I made the assumption (arguably, a design decision) that the fee display screen also handled the verification by the student that the fees were acceptable. This decision should be reflected by my user interface prototype, and verified by my subject matter experts (SMEs). Sequence diagramming is something you should be doing together with your SMEs, particularly sophisticated ones who understand how to develop models such as this.


Keep it simple

As I was modeling Steps 2 and 3, I came to the realization that students should probably have passwords to get into the system. I brought this concept up with my SMEs and discovered I was wrong: the combination of name and student number is unique enough for our purposes and the university didn't want the added complexity of password management. This is an interesting decision that would be documented in the supplementary specification, likely as a business rule, because it is an operating policy of the university. By verifying this idea with my SMEs, instead of assuming I knew better than they did, I avoided an opportunity for goldplating and, thus, reduced the work my team would need to do to develop this system.


Drawing messages and return values

I prefer to draw messages going from left-to-right and return values from right-to-left, although that doesn't always work with complex objects/classes. I align the label on messages and return values, so they are closest to the arrowhead. I prefer not to indicate return values on sequence diagrams to simplify the diagrams whenever possible. However, it is equally valid to always indicate return values, particularly when your sequence diagram is used for design instead of analysis. (I like my analysis diagrams to be as simple as possible and my design diagrams to be as thorough as possible.) During analysis, my goal is to understand the logic and to ensure I have it right. During design, I then flesh out the exact details, as the note reminds me to do with the "qualifications()" message in Figure 1.


Layer your sequence diagrams

I prefer to layer the sequence diagrams from left to right. I indicate the actors, then the controller class(es), and then the user interface class(es), and, finally, the business class(es). During design, you probably need to add system and persistence classes, which I usually put on the right-most side of sequence diagrams. Layering your sequence diagrams in this manner often makes them easier to read and also makes it easier to find layering logic problems, such as user interface classes directly accessing persistence classes (more on this in a future modeling tip).


Follow a consistent logic style

Note that the style of logic changed part way through the sequence diagram of Figure 1. The user interface was handling some of the basic logic at first, particularly the login -- yet for selecting the seminar, and then verifying it, the controller class did the work. This is actually a design issue. I wouldn't get too worked up over this but, as always, I suggest choosing one modeling style that works for you and applying it consistently throughout all of your sequence diagrams.


Remember that sequence diagrams are dynamic

You may have heard terms such as dynamic modeling and static modeling bantered about by other developers familiar with object-oriented modeling techniques. You may even have heard arguments about the merits of each style.

Dynamic modeling techniques focus on identifying the behavior within your system, including sequence diagramming and activity diagramming (see "How to draw UML activity diagrams") and UML collaboration diagramming. Meanwhile, static modeling focuses on the static aspects of your system including the classes, their attributes, and the associations between classes. Class models are the main artifact of static modeling as are persistence/data models.

So there really is nothing to debate -- both dynamic and static modeling techniques are required to specify an object-oriented system adequately.


Resources

About the author

Scott W. Ambler is President of Ronin International, a consulting firm specializing in object-oriented software process mentoring, architectural modeling, and Enterprise JavaBeans (EJB) development. He has authored or co-authored several books about object-oriented development, including the recently released The Object Primer 2nd Edition, which covers, in detail, the subjects summarized in this article. He can be reached at scott.ambler@ronin-intl.com and at his Web site at www.ambysoft.com.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java technology
ArticleID=11476
ArticleTitle=Web services programming tips and tricks: UML sequence diagramming with style
publish-date=02012001
author1-email=scott_ambler@ca.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Rate a product. Write a review.

Special offers