Sequence
Diagrams
OOAD + OOP
Week 9
In this lecture
We will:
• Introduce UML diagram
• Sequence diagrams
• Map the sequence diagram into Java code
Sequence diagram
• A way of showing how objects interact
at run-time
• It focuses on the sequence of method
calls between objects involved in a use
case
• A sequence diagram represents the
order of message passing clearly
• Objects of interest are at the top of the
diagram
• The passage of time flows down the
diagram
Example sequence diagram
new AnotherClass(); YourClass yc = new YourClass();
A named
An unnamed
object
object
An
object’s
timeline
A method
call A
method
This method is called after
the doSomething()
method because it is
lower down the timeline
Control of execution
A method calling
another method
in the same
object
The length of a method’s box
indicates how long it runs,
relative to the other
methods in the same
diagram
A frame
Iteration labelled Loop
indicates an
iteration, and
has a
condition
The
border
shows
what is
included
in the
loop
Selection A frame
labelled alt
indicates a
selection
Alternatives
are separated
by a dotted
line
Sequence diagram
• Sequence diagrams are made with
reference to…
• Class diagram
• For class names and method names
• Activity diagrams
• For the sequence of method calls
Example 4: Sequence
diagram
String studentDeatails = new
Student().getDeatils();
You should be able to…
• Describe the following UML diagrams
• Use case diagrams and descriptions
• Activity diagrams
• Class diagrams
• Sequence diagrams
• Draw these diagrams
• In the next lecture we will:
• Look at a complete worked example of UML
modelling and mapping code