Behavior Modeling Week 5 6
Behavior Modeling Week 5 6
OOAD
1
• Used to model object interaction arranged in time
sequence and to distribute use case behavior to classes
• Captures the behavior of a single use case scenario
• Shows some example objects and the messages that are
passed between the objects interacting in the use case.
Sequence
diagrams 2
Object Life Line
Active Objects Long dashed line
Actors of any system trailing the object
or any object that is
valid within the
system
Self call
Message
Sent by one object to Activation Bar
More SD Notations:
Loops & selections 4
• Consider the following pseudo code that dispatches
orders in line. The dispatch procedure will differ
depending on their value
Procedure dispatch
foreach (lineitem)
if( product.value > $10K)
careful.dispatch
else
regular.dispatch
end if
end for
if (needsConfirmation)
messenger.confirm
End procedure
Example.. 5
Selection operator
Encloses behavior
that will be followed
based on a certain frame
Loop Frame
condition
Encloses the
behavior that
will be looped
over
Optional Frame
Notice that it does
not have an
Guard alternative operator
Shows the alternative
flow
When to use
Sequence 7
Diagrams
• Example on drawing sequence diagram
8
State chart
diagrams
9
• A state chart diagram shows the sequences of states that
an object can be in, the events and conditions that cause
the object to reach those states, and the actions that take
place when those states are reached.
• Usually modeled for objects and some classes, to depict
how an individual object changes state when its behavior
is changed
• Similar to activity diagrams in notations
• Also called state machine
• State – the object current condition as reflected by the
values in the attributes eg of state
• Cars motor might be running
• Window might be shut or open
• State is therefore a description of something about the
object that will remain true until something happens 10
State charts
• To model object states of a system
• To model reactive system
• To identify events responsible for state changes
Where to use 11
statechart diagrams
State of the compiler
object when project is
loaded 12
• States
• Transitions
• Decision points
• Events
• Actions & Activities
• Synchronization elements
Elements of a 13
statechart diagram
State
-is the condition of an object
at a moment in time
-Shows the state within a
state diagram
Start State
Shows were a
state diagram
starts. End State
Shows were a
state diagram
Transition ends
-Shows that when something
happened, the object moved
elements 14
• An event corresponds to a message sent to the object asking or
telling it to do something
• Atomic (un-interruptible)
• May cause an object to take transition between states
• Notation: eventName(parameter:type,….)
• includes events from hardware and real-world objects e.g.,
message receipt, input event, elapsed time, …
• Actions show the behavior that happens when an event occurs.
• Notation: action-label / action
• Actions alter the object’s attribute values, thus redefining the object’
state. There are five basic action types that a state can initiate:
• Entry use to specify the action that occur when the state has been
entered
• Exit specify actions that occurs when the state is being left
• Do specifies activity that occurs when the while the state is being
occupied
15
16
Decision points
Drawing std
17
• Chapter 9 & 10, UML Bible
• Chapter 10, UML A Beginner’s Guide, By Jason T. Roff
References 18