Sequence Diagrams Provide a Dynamic View
While class diagrams help you understand the static relationships in a
system, interaction diagrams provide a dynamic view. UML offers two kinds of
interaction diagrams: sequence and collaboration. While Together supports both,
I usually use sequence diagrams to understand how a request to a top-level class
initiates flows of messages in related classes. Suppose I wanted to understand
what's going on in the createDescription() method of the engine.JDOMappingLoader class in Castor's
jdo package. I use the Explorer view
(shown on the left hand side of Figure
5) to navigate to, and highlight, the method. Then I right click to select
the Generate Sequence Diagram option.
 (enlarge) Figure 5 – Selecting a
Method as the Target of a Sequence Diagram
|
The Sequence Diagram creation dialog lets you suppress the mapping of
message flows at selected package boundaries, as shown in Figure
6. You will definitely want to avoid mapping calls at too low a level,
otherwise your diagrams will span hundreds of pages of output and take forever
to generate.
 (enlarge) Figure 6 – A Sequence Diagram That Traces Across Only Two Package
Boundaries
|
When I opted for this level of detail the resulting diagram (partially
reproduced in Figure
7) took about 10 seconds to render. The sequence diagram tells a visual
story of a call to the createDescriptor() method of the JDOMappingLoader class. An instance of JDOMappingLoader named initial calls getMapTo() twice on a ClassMapping object. Then getTable() is invoked on a MapTo object. The rest of the diagram should be
self-explanatory if you know UML. If not, please check out the resources at the
end of this article.
 (enlarge)
Figure 7– A Control Center Sequence Diagram
|
The key point to remember about sequence diagrams is that they save you
time: you no longer have to fire up a debugger and crawl through an execution
trace to figure out what's going on in unfamiliar code.
Last Modified
October 14, 2002
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.
New on the Java Boutique:
New Review:
Time Management Made Easy with the Quartz Enterprise Job Scheduler
Why not just use the Java timer API? This open source scheduling
API boasts simplicity, ease-of-integration, a well-rounded feature
set, and it's free!
New Applet:
Reverse Complement
Reverse Complement is a simple applet that converts DNA or RNA
sequences into three useful formats.
Elsewhere on internet.com:
WebDeveloper Java
Lots of Java information on webdeveloper.com
WDVL Java
Thorough Java resource at the Web Developer's Virtual Library.
ScriptSearch Java
Hundreds of free Java code files to download.
jGuru: Your View of the Java Universe
Customizable portal with online training, FAQs, regular news updates, and tutorials.