Sequence Diagram

“Yes Dear, we should communicate more”

Communication is what the Sequence Diagram is all about. This document maps-out how each class or object communicates with other classes in the Use Case or code package. When planning or development gets this far, you can easily see to what degree your Use Cases are being followed. Now, at the very latest, is the time you should update them. If a case has changed, determine if the deviation was purposeful or due to something the developer didn’t understand. You must clarify the issue as soon as possible. You don’t want to hold-up the development process, but you also can’t allow a feature to be built incorrectly. If it was purposeful, update the Use Case.

At this point your head could be on the block. Simply maintain your posture, turn-on that charm and allow your personality to smooth things over. If you find you must change the Use Case, ensure all the signatories are notified, and get at least an email confirmation that they understand the reason for the deviation and agree with it.

As with the Class Diagram, you may be required to develop the Sequence Diagrams from existing code. There are a couple of tools that help a lot here. Visual Studio is great for creating these diagrams from managed code. Open the project file, choose “View” from the main menu and choose “Object Browser” from the drop-down menu. You can also simply use the short-cut Ctrl + Alt + J.

In the “Object Browser” click on the Project Name – this shows a complete list of all the assemblies’ contents, from interfaces to classes and so on. You can drill-down into the application as deep as you wish. Pretty cool! Click your way through the application’s classes paying attention to the comments window. This window gives you all the information about the class you need to know. If the developer used XML comments to document his classes, a summary will also appear in the comments window. Fill-out your Sequence Diagram as you click through the list. Life doesn’t get any better.

Open Source web applications are a bit more interesting in that some projects often don’t use a lot of classes. They tend to rely more on imperative or functional programming styles. (Of course this depends on what language the solution was written in.) If you are required to map-out specific features, the Sequence Diagram is still a good tool.

Additionally, Firefox has a great extension called the Web Developer Toolbar. This allows you to easily identify and manipulate parts of the user interface, which normally could be hassle to look through manually. You can make temporary changes to the CSS and see how it influences the page in almost-real-time, or identify portions of HTML markup. You can even have the extension show you the identifiers of each element in the markup, draw a border around block-level elements, show a list of images embedded in the page, and more. A real gem.

Here’s one last, rather trivial tip. Depending on what language you’re using, reading code from right to left helps pay attention to how the expression relates to itself. Consider this piece of C# code:

// this.serverInformation is an instance of the ServerInfo class.
XMLDocument xmldoc = new RemoteXMLDocument(new FTPSocket(this.serverInformation), SocketSecurity.None, new IPv6Address(this.serverInformation.ipv6Address));

Reading it backwards, we see that we’re opening a socket using IPv6, which is unsecured, to an FTP server using information stored in the class, which is used to fetch an XML document that is going to be assigned to the xmldoc XML Document instance.

Articles Additional Resources

These are some helpful locations where you can gain a better understanding of Sequence Diagrams.
Sequence Diagram article on Wikipedia
UML 2 Sequence Diagrams by Scott Ambler
Download the Web Developer Toolkit for Fire Fox

Example

Here is an example of a Sequence Diagram in progress. It is not filled-out completely because the system was still in development and the classes were not finalized. Working in “fluid” environments is one reason there’s hardly a more exciting job than software development.
Sequence Diagram Example

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.