UML Sequence Diagrams

U
M
L
 
R
e
v
i
e
w
S
e
q
u
e
n
c
e
 
D
i
a
g
r
a
m
s
SE-2030
Dr. Mark L. Hornick
1
Sequence diagram from SE1021 Lab 9:
http://people.msoe.edu/~hornick/Courses/se1021/labs/se1021_Drawing%20Program%202010%20Part%202.htm
SE-2030
Dr. Mark L. Hornick
2
What does a Sequence
diagram illustrate?
S
t
a
r
t
u
p
 
S
e
q
u
e
n
c
e
 
D
i
a
g
r
a
m
public class ATM {
 
private static Account checking = new Account();
 
private static Account savings = new Account();
 
private ATM() {
 
}
 
public static void main(String[] args) {
            // perform some initial transactions
            boolean status = checking.withdraw(100);
 
 
     status = savings.deposit(100);
       }
 
} //end ATM
SE-2030
Dr. Mark L. Hornick
3
ATM
checking : Account
savings : Account
status = withdraw(100);
status = deposit(100);
main();
S
e
q
u
e
n
c
e
 
d
i
a
g
r
a
m
s
 
i
l
l
u
s
t
r
a
t
e
 
h
i
g
h
-
l
e
v
e
l
i
n
t
e
r
a
c
t
i
o
n
s
 
(
m
e
t
h
o
d
 
c
a
l
l
s
)
 
b
e
t
w
e
e
n
 
c
l
a
s
s
i
n
s
t
a
n
c
e
s
A UML Sequence Diagram represents 
classes and/or class instances
(objects) and their interactions with one another
Classes and objects can interact with one another in many different
ways during the course of execution of a program
A given Sequence Diagram 
shows just one interaction 
for a specific
circumstance (e.g. startup, shutdown, processing a single button
click,…)
SE-2030
Dr. Mark L. Hornick
4
ATM
checking : Account
savings : Account
status = withdraw(100);
status = deposit(100);
main();
N
o
t
a
t
i
o
n
 
&
 
r
e
p
r
e
s
e
n
t
a
t
i
o
n
The 
name of the class 
appears at the top of a Sequence Diagram
rectangle, 
which can also (optionally) include the name of the object
representing a particular instance of that class:
U
M
L
 
S
y
n
t
a
x
:
 
[
<
o
b
j
e
c
t
_
n
a
m
e
>
 
]
:
 
<
c
l
a
s
s
_
n
a
m
e
>
SE-2030
Dr. Mark L. Hornick
5
chkAcct : Account
c
h
k
A
c
c
t
 
i
s
 
t
h
e
 
n
a
m
e
 
o
f
 
t
h
e
 
r
e
f
e
r
e
n
c
e
t
o
 
a
n
 
i
n
s
t
a
n
c
e
 
o
f
 
a
n
 
A
c
c
o
u
n
t
N
o
t
a
t
i
o
n
 
a
n
d
 
r
e
p
r
e
s
e
n
t
a
t
i
o
n
SE-2030
Dr. Mark L. Hornick
6
ATM
checking : Account
cm: CashMachine 
      withdraw(100);
main();
status = deposit(100);
dispenseCash(100);
balance = checkAcctBalance();
amountOK = hasCash(100);
status
 wasAccepted = acceptEnvelope();
This rectangle represents the
duration of the main() method call
The vertical dotted lines are 
called lifelines
This represents the withdraw() method
calling the checkBalance method in the same class
Time passes in this
direction
The stick figure 
represents the user
or the op sys
S
o
m
e
t
i
m
e
s
,
 
y
o
u
 
m
a
y
 
w
a
n
t
 
t
o
 
s
h
o
w
 
c
o
n
d
i
t
i
o
n
a
l
l
o
g
i
c
 
(
s
e
l
e
c
t
i
o
n
)
 
i
n
 
a
 
S
e
q
u
e
n
c
e
 
D
i
a
g
r
a
m
-
a
l
t
h
o
u
g
h
 
t
h
i
s
 
i
s
 
u
s
u
a
l
l
y
 
t
o
o
 
m
u
c
h
 
d
e
t
a
i
l
 
t
o
 
s
h
o
w
a
t
 
t
h
i
s
 
l
e
v
e
l
SE-2030
Dr. Mark L. Hornick
7
ATM
checking : Account
cm: CashMachine 
      withdraw(100);
main();
deposit(100);
[if amountOK==true] 
dispenseCash(100);
balance = checkAcctBalance();
[if balance>100] 
amountOK = hasCash(100);
status
 wasAccepted = acceptEnvelope();
This rectangle represents the
duration of the main() method call
The vertical dotted lines are 
called lifelines
This represents the withdraw() method
calling the checkBalance method in the same class
Time passes in this
direction
S
i
m
i
l
a
r
l
y
,
 
y
o
u
 
c
a
n
 
i
l
l
u
s
t
r
a
t
e
 
i
t
e
r
a
t
i
o
n
SE-2030
Dr. Mark L. Hornick
8
ATM
checking : Account
cm: CashMachine 
      withdraw(100);
main();
deposit(100);
*[while<100]
dispenseCash(20);
balance = checkAcctBalance();
amountOK = hasCash(100);
status
 wasAccepted = acceptEnvelope();
This rectangle represents the
duration of the main() method call
The vertical dotted lines are 
called lifelines
This represents the withdraw() method
calling the checkBalance method in the same class
Time passes in this
direction
Slide Note
Embed
Share

UML Sequence Diagrams illustrate high-level interactions between class instances in software programs. They represent method calls and interactions among objects during program execution. The diagrams show interactions for specific circumstances like startup or button clicks. Each class/object is represented with a rectangle, and interactions are shown with lifelines and method calls. Stick figures may represent users or operating systems. Notation includes class/object names at the top of rectangles for clarity.

  • UML
  • Sequence Diagrams
  • Software Development
  • Object-Oriented Programming

Uploaded on Sep 17, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. UML Review Sequence Diagrams SE-2030 1 Dr. Mark L. Hornick

  2. Sequence diagram from SE1021 Lab 9: http://people.msoe.edu/~hornick/Courses/se1021/labs/se1021_Drawing%20Program%202010%20Part%202.htm What does a Sequence diagram illustrate? SE-2030 2 Dr. Mark L. Hornick

  3. Startup Sequence Diagram public class ATM { private static Account checking = new Account(); private static Account savings = new Account(); private ATM() { } public static void main(String[] args) { // perform some initial transactions boolean status = checking.withdraw(100); status = savings.deposit(100); } } //end ATM checking : Account ATM savings : Account main(); status = withdraw(100); status = deposit(100); SE-2030 3 Dr. Mark L. Hornick

  4. Sequence diagrams illustrate high-level interactions (method calls) between class instances A UML Sequence Diagram represents classes and/or class instances (objects) and their interactions with one another Classes and objects can interact with one another in many different ways during the course of execution of a program A given Sequence Diagram shows just one interaction for a specific circumstance (e.g. startup, shutdown, processing a single button click, ) checking : Account ATM savings : Account status = withdraw(100); status = deposit(100); main(); SE-2030 4 Dr. Mark L. Hornick

  5. Notation & representation The name of the class appears at the top of a Sequence Diagram rectangle, which can also (optionally) include the name of the object representing a particular instance of that class: UML Syntax: [<object_name> ]: <class_name> chkAcct : Account chkAcct is the name of the reference to an instance of an Account SE-2030 5 Dr. Mark L. Hornick

  6. Notation and representation checking : Account ATM cm: CashMachine withdraw(100); balance = checkAcctBalance(); This represents the withdraw() method calling the checkBalance method in the same class main(); This rectangle represents the duration of the main() method call amountOK = hasCash(100); The stick figure represents the user or the op sys dispenseCash(100); status status = deposit(100); wasAccepted = acceptEnvelope(); Time passes in this direction The vertical dotted lines are called lifelines SE-2030 6 Dr. Mark L. Hornick

  7. Sometimes, you may want to show conditional logic (selection) in a Sequence Diagram -although this is usually too much detail to show at this level checking : Account ATM cm: CashMachine withdraw(100); balance = checkAcctBalance(); This represents the withdraw() method calling the checkBalance method in the same class main(); This rectangle represents the duration of the main() method call [if balance>100] amountOK = hasCash(100); Time passes in this direction [if amountOK==true] dispenseCash(100); status deposit(100); wasAccepted = acceptEnvelope(); The vertical dotted lines are called lifelines SE-2030 7 Dr. Mark L. Hornick

  8. Similarly, you can illustrate iteration checking : Account ATM cm: CashMachine withdraw(100); balance = checkAcctBalance(); This represents the withdraw() method calling the checkBalance method in the same class main(); This rectangle represents the duration of the main() method call amountOK = hasCash(100); Time passes in this direction *[while<100]dispenseCash(20); status deposit(100); wasAccepted = acceptEnvelope(); The vertical dotted lines are called lifelines SE-2030 8 Dr. Mark L. Hornick

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#