0% found this document useful (0 votes)
17 views23 pages

State Transition Diagram

Uploaded by

jaspinder257
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views23 pages

State Transition Diagram

Uploaded by

jaspinder257
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 23

State Chart Diagrams

by
AshimaSingh
Associate
Professor,
TIET
State

• The current state o/ an object is determined by the current


value o/ the object’s attributes and the links that it has
with other objects
• For e/ample the class Sta//Member has an attribute
startDate which determines whether a Sta//Member
object is in the probationary state

2
State

• ‘A state is a condition during the life of an


object or an interaction during which
it satisfies some condition, performs
some action or waits for some
event....
Conceptually, an object remains in a
state for an interval of time. However,
the semantics allow for modelling "flow-
through" states which are instantaneous
as well as transitions that are not
instantaneous.’
3
Statechart
• The current state of a GradeRate
object can be determined by the
two attributes rateStartDate and
rateFinishDate
• An enumerated state variable
may be used to hold the object
state, possible values would be
Pending, Active or Lapsed

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

• Events This event must correspond to an


operation in the Campaign
Commissione class
d

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

Exiting the state


triggers
While the object remains in hideMenu()
the Menu Visible
state, the activity causes a
sound clip to be played
9
/
Action-expression assignManager(
assignStaff
assigning manager );() Commissione
and staff on object d
creation authorized(authorizationCo
de)
[contract signed]
/ Recursive transition
Statechart for setCampaignActive models any payment
()
the class Activ event that does not
Campaign e reduce the amount due
campaignComplete
to zero or beyond
/d()
Guard condition prepareFinalStatemen
ensuring complete t()
payment before Complete
entering Paid d
paymentReceived(paym
paymentReceived(paym
ent)
[paymentDue – payment <= zero]
ent) [paymentDue - payment >

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

• A transition to a complex state is equivalent to a


simultaneous transition to the initial states of
each concurrent statechart
• An initial state must be specified in both nested
statecharts in order to avoid ambiguity about
which substate should first be entered in each
concurrent region
• A transition to the Active state means that
the Campaign object simultaneously enters
the Advert Preparation and Survey
states
15
Concurrent States
• Once the composite states is entered a
transition may occur within either concurrent
region without having any effect on the state
in the other concurrent region
• A transition out of the Active state
applies to all its substates (no matter how
deeply nested)

16
Synchronized Concurrent Threads.

Synchronization bar

● Explicitly showing how an event triggering a


transition to a state with nested concurrent states
causes specific concurrent substates to be entered
● Shows that the composite state is not exited
until both concurrent nested statecharts are
exited
17
Preparing Statecharts
• Two approaches may be used:
– Behavioural approach
– Life cycle approach

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();

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy