Dynamic Modeling: Grady Booch, James Rumbaugh, and Ivar Jacobson, Edition, Addison Wesley, 2005
Dynamic Modeling: Grady Booch, James Rumbaugh, and Ivar Jacobson, Edition, Addison Wesley, 2005
Outline
Dynamic models
State machine diagrams (a.k.a. statechart)
Modeling object states
Interaction diagrams
Sequence diagrams (a.k.a. message sequence)
The time order of interactions between objects
Dynamic Models
Used to model control aspects (e.g., when)
Several different models possible, e.g.,
Focusing on state changes
Focusing on interactions
Dynamic Models
Used to model control aspects (e.g., when)
Several different models possible, e.g.,
Focusing on state changes
Focusing on interactions
Dynamic Models
Used to model control aspects (e.g., when)
Several different models possible, e.g.,
Focusing on state changes
Focusing on interactions
Used to show dynamic relationships between objects
Messages, interfaces, and timings
UML interaction diagrams
Sequence diagrams, focusing on ordered interactions
Communication diagrams, focusing on interaction links
Timing diagrams, focusing on interaction timings
5
Outline
Dynamic models
State machine diagrams
Interaction diagrams
Off
switch pushed
8
Initial State
Transition
Running
Idle
State
9
checkmate
Black
win
stalemate
start
black
moved
white
moved
Blacks turn
stalemate
checkmate
Draw
White
win
10
States
Condition or situation in the life of a system (or
object) during which it:
Satisfies some condition,
Performs some activity, or
Waits for some events.
States (Cont.)
All objects have states.
A state is an abstraction of the values
maintained by the object that determine
behavior.
Examples:
Identifying States
Ignore attributes that don't affect
behavior
Combine set of attributes that form a
parameter of the control
E.g., the control is not changed by
changing the digits in the phone call.
14
Specifying States
Name (optional)
Internal activities (optional)
Actions and activities performed while in the state
Predefined: entry, exit, do
Brewing
do / brew coffee
pot removed/ suspend
pot replaced/ resume
15
Attacking
entry/unsheathe sword
do/charge
exit/sheathe sword
enemy swings[distance<3 ft]/dodge
Internal transitions
Reactions to events that doesnt
cause state changes (see transitions)
16
Example
[number.isValid()]
Starting
entry / start dial tone
exit / end dial tone
dialed (n)
Dialing
entry / number.append(n)
dialed (n)
17
Events
Something that happens at a point in time
No duration: instantaneous
At least we think of it this way when we model
(abstraction)
18
Two Events:
May be unrelated (concurrent)
E.g., flight 123 departs El Paso and flight
555 departs Las Vegas.
19
Transitions
Relationship between two states indicating
that a system (or object) in the first state will:
Perform certain actions and
Enter the second state when specified event
occurs and specified condition is satisfied.
Consists of:
Source and target states
Optional event trigger, guard condition, and action
trigger [guard] / action
Source
Target
21
Transitions (Cont.)
Source state
State affected by transition
Event trigger
Source
Guard condition
Boolean evaluated after the
event trigger. Transition only
occurs if guard is true
Action
Atomic operation that occurs as
the transition occurs
Target
Target state
State active after transition
22
Example
trigger [guard] / action
Source
Target
Transitions (Cont.)
Lead from one state to another
Instantaneous
Several types of events:
24
Phone Example
digit dialed (n)
[incomplete]
connected
Dialing
digit dialed (n)
[invalid]
Ringing
Connecting
busy
Busy
Invalid
25
Another Example
recovery success
recovery failure
Normal
anomaly
Recovery
Identification
pressure
problem
recovery
success
recovery
success
Pressure
Recovery
temperature
problem
Temperature
Recovery
recovery
failure
recovery
failure
26
28
anomaly
Recovery
Identification
pressure
problem
recovery
success
recovery
success
Pressure
Recovery
temperature
problem
recovery
Unstructured!failure
Temperature
Recovery
recovery
failure
29
Better Presented:
anomaly
Recovery
Recovery
Identification
Normal
recovery
success
recovery
failure
pressure
problem
Pressure
Recovery
temperature
problem
Temperature
Recovery
30
31
Validating
Selecting
Processing
Maintenance
Printing
Transition from substate
32
Dialing
[number.isValid()]
Starting
entry / start dial tone
exit / end dial tone
dialed(n)
Partial Dialing
entry / number.append(n)
dialedn)
33
Parallel Composition
Concurrency (split of control)
Synchronization
Superstate
substate1
substate2
substate3
substate4
34
Example Parallel
Composite state
Fork
Maintaining
Idle
Testing
Testing
Diagnose
Join
Commanding
Waiting
Command
Concurrent States
35
Another Example
Incomplete
HW1
HW2
Passed
Project
Midterm
Final
fail
Failed
36
Example of Synchronization
Play
Remote Control
Off
On
On
Off
Stop
On
Off
MP3 Player
Play
On/Stop
Off
Stop
On/Play
Off/Stop
37
38
39
Outline
Dynamic models
State machine diagrams
Interaction diagrams
40
Modeling Interactions
Focus on communications among
elements
Ordering of interactions
Messages and interfaces
Communication links
Timings of messages (between when
message sent and received)
41
Communication Diagrams
Messages passed between objects
Timing Diagram
Interactions with precise time axis (for real-time or timesensitive systems)
42
Sequence Diagrams
Depicts object interaction by
highlighting the time ordering of method
invocations
Describes a sequence of method calls
among objects
(This is the only interaction diagram
well look at.)
43
Example
sdPlaceOrder
: Customer
: Order
: Payment
: Product
: Supplier
object
place an order
control
process
lifetime
validate
if ( payment ok )
deliver
if ( not in stock )
back order
get address
message
mail to address
44
Example (Cont.)
: Customer
: Order
: Payment
: Product
: Supplier
place an order
process
validate
if ( payment ok )
deliver
if ( not in stock )
back order
get address
mail to address
45
o: Class
Creation message
Destruction message
46
Return Messages
sdPlaceOrder
:CustomerWIndow
Change
Update
:Customer
Return
(dashed line,
open arrow)
47
:CustomerWIndow
Change
<<create>>
:Customer
getRating()
<<destroy>>
48
49