State Transition Diagram
State Transition Diagram
by
AshimaSingh
Associate
Professor,
TIET
State
2
State
4
STD
GradeRate()
Pendin
g
Statechart
[rateStartDate
<= currentDate]
Initial state Statechart for
Change the class
Activ
event GradeRate.
e
[rateFinishDate
Transition
<= currentDate]
Movement from
between one state to
states
another is
Lapse dependent upon
d events that
[1
year] occur with the
Elapsed-time passage of time.
event
Final state
5
Types of Event
• A change event occurs when a condition becomes
true
• A call event occurs when an object receives a call
to one of its operations either from another
object or from itself
• A signal event occurs when an object receives a
signal (an asynchronous communication)
• An elapsed-time event is caused by the passage of
a designated period of time after a specified
event (frequently the entry to the current state)
6
Events
authorized(authorizationCode) [contract
Signed]
/setCampaignActive( )
Acti
v
e
7
Actions and Activities
Internal actions and
activities for a state
Internal
transition Name
compartmen compartment
t
State
Name
entry / action
A state may
expression exit/
include a
action expression
sub-
do / activity
statechart
include / submachine
8
Menu Visible
State
Menu Visible state for Event itemSelected()
a triggers the action
DropDownMenu object highlightItem()
Entry action
causes the menu
to be displayed
zero] Paid
archiveCampaign()
/unassignStaff();
unassignManage
r()
10
/
assignManager(
assignStaff
Commissione
);()
d
authorized(authorizationCo
de) [contract signed]
/setCampaignActive()
A revised Activ
statechart for the e
campaignCompleted()
class Campaign /
paymentReceived(payment) prepareFinalStatemen
[paymentDue - payment < t()
If the user
/zero]
requirements were Complete
generateRefund
to change, so that d
() paymentReceived(paym
an overpayment is ent)
[paymentDue - payment = zero]
now to result in [paymentDue – payment >
the automatic paymentReceived(payment)
zero]
generation of a
Paid
refund, a new
archiveCampaign
transition is added ()
/unassignStaff();
unassignManage
r() 11
Nested Substates
The transition from the initial pseudostate
The Active state symbol should not be labelled with an
Campaign showing
of event but may be labelled with an action,
though it is not required in this example
nested substates
Activ
e
extendCampaig advertsApprove
n() d()
Advert
/modify /authorize()
Preparation
Budget()
Running Schedulin
Adverts confirmSchedul g
e()
campaignCompleted()
/
prepareFinalStatemen
t()
12
Nested States
The submachine
Running is
The Active state referenced using the
include statement
of Campaign with
the detail hidden
Active
include / Running
Hidden
decomposition
indicator icon
13
The Active State with
Concurrent Substates
Activ
e
Running
extendCampaig advertsApprove
n() Advert d()
/modify Preparation /authorize()
Budget() confirmSchedul
Running Schedulin
e()
Adverts g
campaignCompleted()
/
prepareFinalStatemen
Monitorin t()
surveyComplet
g Surve
e()
y
Evaluatio
runSurvey n
()
14
Concurrent States
16
Synchronized Concurrent Threads.
Synchronization bar
18
Behavioural Approach
1. Examine all interaction diagrams that involve
each class that has heavy messaging.
2. Identify the incoming messages on each
interaction diagram that may correspond to
events. Also identify the possible
resulting states.
3. Document these events and states on a
statechart.
4. Elaborate the statechart as necessary to cater
for additional interactions as these become
evident, and add any exceptions.
19
Behavioural Approach
5. Develop any nested statecharts (unless this has
already been done in an earlier step).
6. Review the statechart to ensure consistency with
use cases. In particular, check that any
constraints that are implied by the statechart are
appropriate.
7. Iterate steps 4, 5 and 6 until the statechart
captures the necessary level of detail.
8. Check the consistency of the statechart with the
class diagram, with interaction diagrams and
with any other statecharts and models.
20
/
assignManager(
assignStaff
Commissione
);()
d
authorized(authorizationC
ode) [contract signed]
/setCampaignActive()
extendCampaig advertsApprove
Initial statechart n()
/modify
Advert d()
/authorize()
Preparation
for the Budget()
Running
confirmSchedul
Schedulin
e()
Campaign Adverts
campaignCompleted()
g
/
class—a prepareFinalStatemen
paymentReceived(payment
t()
behavioural ) [paymentDue - payment
/< zero] Complete
approach generateRefund
() paymentReceived(paym
d
ent)
[paymentDue - payment = paymentReceived(payment)
zero] [paymentDue – payment >
zero]
Paid
archiveCampaign()
/unassignStaff();
unassignManage
r()
21
/
assignManager(
assignStaff
Commissione
);()
d
authorized(authorizationC
ode) [contract signed]
/setCampaignActive()
Active
extendCampaig advertsApprove
Revised n()
/modify
Advert
Preparation
d()
/authorize()
statechart for Budget()
Running Schedulin
confirmSchedul
the Campaign Adverts
e()
campaignComplete
g
class /
d()
prepareFinalStatemen
t()
paymentReceived(payment
) [paymentDue - payment
/< zero] Complete
generateRefund d
() paymentReceived(paym
ent)
[paymentDue - payment = paymentReceived(payment)
zero] [paymentDue – payment >
zero]
Paid
archiveCampaign
() 22
/unassignStaff();
/
assignManager(
Commissione
); assignStaff()
d
authorized(authorizationCo
de) [contract signed]
/setCampaignActive()
Activ
e
Monitoring surveyComplet
Surve
e()
y
Final runSurvey
Evaluatio
n
version of Runnin
()
g extendCampaig advertsApprove
Campaign campaignCancelle
d()
n()
/modify
Advert d()
/authorize()
Preparation
statechart
/calculateCosts();
prepareFinalStatemen Budget()
t() Running Schedulin
Adverts confirmSchedul g
e()
campaignCancelle
d() campaignCompleted()
/ /
cancelSchedule
prepareFinalStatement() prepareFinalStatemen
() t()
Complete
calculateCosts( d
paymentReceived(payment));
paymentReceived(payment)
[paymentDue - payment < paymentReceived(payment)
[paymentDue - payment =
zero] [paymentDue – payment >
zero]
/generateRefund() zero]
archiveCampaign( Paid
) 23
/unassignStaff();