State Chart Diagram: By: Bhavsar Jenish Roll No: 08

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 18

State Chart

Diagram
By: Bhavsar
Jenish
Roll No : 08

State Chart Diagram


State-transition diagrams describe all of the states
that an object can have, the events under which an
object changes state (transitions), the conditions
that must be fulfilled before the transition will occur
(guards), and the activities undertaken during the
life of an object (actions).

In comparison the other behavioral diagrams


which model the interaction between multiple
classes, State diagrams typically model the
transitions within a single class.
It also shows how an entity responds to various
events by changing from one state to another.
In most OO techniques, state diagrams are drawn
for a single class to show the lifetime behavior of a

Elements of State Chart


Diagram

1. Initial State: This shows the


starting point or first activity of the
flow. Denoted by a solid circle. This
is also called as a "pseudo state,"
where the state has no variables
it further and
2. describing
State: Represents
the no
activities.
state of object at an
State Name
instant of time. In a state
diagram, there will be
State Variables
multiple of such symbols,
one for each state of the
Action
Object we are discussing.
Denoted by a rectangle
with rounded corners and
Contd
compartments (such as a

3. Transition:

An arrow indicating the Object to


transition from one state to the other.
The actual trigger event and action
causing the transition are written
beside the arrow, separated by a slash.Event/Action

Transitions that occur because the state


completed an activity are called
"triggerless" transitions.

If an event has to occur after the


completion of some event or action, the
event or action is called the guard
condition. The transition takes place
after the guard condition occurs. This
guard condition/event/action is
depicted by square brackets around the

Contd

4. Signal: When an event


causes a message/trigger to be
sent to a state, that causes the
transition; then, that message
sent by the event is called a
signal. Represented as a class
with the <<Signal>> icon
above the action/event.
5. Final State: The end of
the state diagram is shown by a
bull's eye symbol, also called a
final state. A final state is
another example of a pseudo
state because it does not have
any variable or action
described.

<<Signal>>
Event/Action
Event/Action

Contd

6. Iterations: Whenever
there is repetition of any
action which does not make
a transition to another state
instead the same state
reoccurs the transition is
shown as given. This
transition is known as a
self-transition. Here the
source
and target
states are
7. Decision
Making:
same.
Whenever there is a
requirement to check a given
condition before any
transition occurs then the
condition is specified in [ ]
brackets.

State

State1
Event/Ac
tion
[ conditio
n]

State2

8. Region: A region is an orthogonal part of


either a composite state or a state machine. It
contains states and transitions.

Lab1

Studyi
ng

Lab2

project
First test
Fail
Failed

Passed

Different States of State Chart


Diagram

1. Choice pseudo state: A choice vertices which,


when reached, result in the dynamic evaluation of the
guards of the triggers of its outgoing transitions. This
realizes a dynamic conditional branch. It allows
splitting of transitions into multiple outgoing paths
such that the decision on which path to take may be
a function of the results of prior actions performed in
the same run-to-completion step.
The boolean
State2
[ a=5]
conditions specified are
known as guards.

State1

ID

State3

[ <=10
]

[ >10] State4

Contd

2. Composite State: A composite state is either


a simple composite state (with just one region) or
an orthogonal state (with more than one region).

State1

Event/Ac
[ conditio
tion
n]

State2

3. Submachine State: A submachine state


specifies the insertion of the specification of a
submachine state machine. The state machine that
contains the submachine state is called the
containing state machine. The same state machine
may be a submachine more than once in the
context of a single containing state machine.
Contd

4. Junction Pseudostate: A junction vertices are


semantic-free vertices that are used to chain
together multiple transitions. They are used to
construct compound transition paths between
states.

State1

State1

E1 [b
< 0]

[a < 0]

State1

E2 [b
< 0]
[a = 5]

State1

[a >7]

State1

Contd

5. History Deep Pseudostate: A deepHistory


represents the most recent active configuration of
the composite state that directly contains this
pseudostate; e.g. the state configuration that was
active when the composite state was last exited.

A2

A1

Interrupt

H*

resume

Contd

6. History Shallow Pseudostate: A


shallowHistory represents the most recent active
substate of its containing state (but not the
substates of that substate). A composite state can
have at most one shallow history vertex.

A1

A2

Interrupt

resume

Contd

7. Entry Point Pseudostate: Sometimes you wont


want to enter a sub-machine at the normal initial
state. For example, in the following sub-machine it
would be normal to begin in the "Initializing" state,
but if for some reason it wasnt necessary to perform
the initialization, it would be possible to begin in the
Intialized" state by transitioning to the named entry
point.

A1

A2

Initializing

Initialized

A3
Skip A1

Contd

8. Exit Point Pseudostate: An exit point


pseudostate is an exit point of a state machine or
composite state. Entering an exit point within any
region of the composite state or state machine
referenced by a submachine state implies the exit of
this composite state or submachine state and the
triggering of the transition that has this exit point as
source in the state machine enclosing the submachine
Failed to
or composite state.
ReadWriting
Reading

instructions

Error report

Processing
instructions

Displaying
Results

Processing

Contd

9. Terminate Pseudostate: Entering a terminate


pseudostate implies that the execution of this state
machine by means of its context object is terminated.
The state machine does not exit any states nor does it
perform any exit actions other than those associated
with the transition leading to the terminate
pseudostate.
Lift
receiver /
get dial
tone
State

Caller
hangs
up

Active

Terminate

When to use the State Chart


Diagrams

Critical to workflow and workgroup applications.


Critical to processing any documents.
Critical to speeds, feeds and flows, sometimes
called Control applications.
Modelling a real-time processing application.
Shows behaviour of a class over several usecases.

Thanks
!!

You might also like