UML Sequence Diagrams
for Process Views
CSE 403, Spring 2007, Alverson
With some material from MartyStepp lectures, Wi07.
Outline
y UML class diagrams – recap
y UML sequence diagrams
y UML wrapup
y SDS template
More detail:
y http://dn.codegear.com/article/31863#sequence-diagrams
y http://www-128.ibm.com/developerworks/rational/library/3101.html
y http://www.awprofessional.com/articles/article.asp?p=169507&rl=1
CSE 403, Spring 2007, Alverson
UML classes
y class name
y attributes - all data fields of the object
o visibility name : type
y operations – omit trivial, inherited methods
o visibility name (parameters) : return_type
y visibility:+ public
# protected
- private
y underline static values
CSE 403, Spring 2007, Alverson
Class relationships
y generalization – inheritance between classes
y association – connection between classes
o dependency
Solid line, or dotted if temporary dependency
o aggregation
class contains another class
composition variation
contained class will not exist without the container class
o multiplicity, navigability
CSE 403, Spring 2007, Alverson
Generalization
Relationship exercise Association
Aggregation
Composition
Leap Year
Table
Calendar Calendar
Entry
Executive Conference
Calendar Room
CSE 403, Spring 2007, Alverson
UML Sequence Diagrams
sequence diagram:
details how operations are carried out -- what
messages are sent and when
y capture the process view of an architecture – provide a
dynamic view of behavior
y organized according to time - time progresses as you go
down the page
y objects are listed from left to right, based on when they
take part in the message sequence
CSE 403, Spring 2007, Alverson
MVP Sequence diagram
CSE 403, Spring 2007, Alverson
How do you start?
1. Identify the process/algorithm/activity you
want to capture (may be a use case)
2. Identify the major objects involved
3. Map out the flow of control/messages to
achieve the result
CSE 403, Spring 2007, Alverson
Representing objects
InstanceName
InstanceName::ClassName
ClassName
object of
object anonymous object unknown class
Alverson : Instructor : Instructor Alverson
lifeline
CSE 403, Spring 2007, Alverson
Messages between objects
y message (method call) indicated by
horizontal arrow to other object
o with message name and arguments above
arrow
method name Alverson : Instructor
requestClassGrades(ClassID)
method argument types
CSE 403, Spring 2007, Alverson
More on messages
y message indicated by horizontal arrow
o dashed arrow back indicates return
o different arrowheads for normal / concurrent
(asynchronous) methods
Levy : DepartmentHead Alverson : Instructor
requestClassGrades(ClassID)
type of
return value Grades synchronous
(full arrow)
return giveRaise(BigNumber)
(dashed line)
CSE 403, Spring 2007, Alverson asynchronous
(half arrow)
Indicating method calls
y activation: thick box over : Instructor : Student
object's life line; drawn
giveTest(Test)
when object's method is
on the stack
o either that object is running
its code, or
o it is on the stack waiting for Results
another object's method to
finish
Results
activation
CSE 403, Spring 2007, Alverson
Lifetime of objects
y creation: arrow with 'new'
: Instructor creation
written above it
o an object created after the
start of the sequence new : Survey
appears lower than the
others
y deletion: an X at bottom of
object's lifeline
Results
o how do objects get deleted
in java? in C?
CSE 403, Spring 2007, Alverson
deletion
Conditionals and loops (UML2)
iteration frame
loop
control
condition
control
if/then/else
frame
if/then
frame
CSE 403, Spring 2007, Alverson
Example sequence diagram #1
UML1 style of
iteration and
conditionals
CSE 403, Spring 2007, Alverson
Example sequence diagram #2
object calls
itself
CSE 403, Spring 2007, Alverson
Using visio to create a SD
y Create a sequence diagram to represent a
skier booking a lesson
y Objects: Skier, Booking System, Calendar
CSE 403, Spring 2007, Alverson
Forms of system control
y What can you say about the control flow of each
of the following systems?
o Is it centralized?
o Is it distributed?
o Does the sequence diagram help show this?
CSE 403, Spring 2007, Alverson
What control pattern?
CSE 403, Spring 2007, Alverson
What control pattern?
CSE 403, Spring 2007, Alverson
What’s wrong with this SD?
y Look at the UML syntax and the viability of the scenario
CSE 403, Spring 2007, Alverson
What about with this one?
CSE 403, Spring 2007, Alverson
Why not just code it?
y Sequence diagrams can be somewhat close to
the code level. So why not just code up that
algorithm rather than drawing it as a sequence
diagram?
a good sequence diagram is still above the level of
the real code
sequence diagrams are language-agnostic
non-developers can do sequence diagrams
can see many objects/classes at a time on same
page (visual bandwidth), enabling
easier understanding
easier review for correctness
CSE 403, Spring 2007, Alverson
UML closing thoughts
y What’s good about UML?
o A common language
makes it easier to share requirements, specs, designs
o Visual syntax is good
summarizes information
good for non developers/less technical
o Tool support is available
Visio, Violet, Rational, Eclipse (June 2007), …
Some tools convert from UML to code
o your thoughts?
CSE 403, Spring 2007, Alverson
UML closing thoughts
y What’s not so good?
o Rich language (good and bad)
o Visual syntax does not always work or scale
Features hard to depict
Large diagrams would be required, which are hard
to understand
y UML is happening!
o UML is widely known by users, tool vendors,
developers, customers
o Seems a step forward – a standard language for
representing software architecture and design
CSE 403, Spring 2007, Alverson