0% found this document useful (0 votes)
18 views17 pages

State Diagram

The document explains UML State Machine Diagrams, which illustrate the events, states, and transitions of an object's behavior in response to events. It covers key concepts such as events, states, transitions, nested states, and the differences between state-independent and state-dependent objects. Additionally, it provides examples and notations for better understanding of state machine modeling.

Uploaded by

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

State Diagram

The document explains UML State Machine Diagrams, which illustrate the events, states, and transitions of an object's behavior in response to events. It covers key concepts such as events, states, transitions, nested states, and the differences between state-independent and state-dependent objects. Additionally, it provides examples and notations for better understanding of state machine modeling.

Uploaded by

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

UML State Machine

Diagrams and
Modeling
State Machine Diagram
• These diagrams illustrates the interesting
events and states of an object and the
behavior of an object in reaction to an
event.
• The state diagram shows the life cycle of
the object.
• Sometimes it is not possible to show each
and every event in the state diagram.
Events, states and transitions
– Event: significant occurrence of something..
• E.g., customer inserts ATM card.
– State: it is a condition of an object at a moment in
time (between events).
ex waiting for user to enter PIN
authenticating the user
dispensing cash (these states represent the
object is waiting for something or doing something.)
– Transition: a relationship between two states; when
an event occurs, the object moves from the current
state to a related state
ex when a system performs “startup” the transition
from ideal state to active state.
UML State Machine Diagram
• States shown as rounded rectangles.
• Transitions shown as arrows.
• Events shown as labels on transition
arrows.
• Initial pseudo-state automatically
transitions to a particular state on object
instantiation.
• Events with no corresponding transitions
are ignored.
State machine diagram for a telephone
Transition Actions and Guards
• A transition can cause an action to fire.
– In software implementation, a method of the
class of the state machine is invoked.
• A transition may have a conditional guard.
– The transition occurs only if the test passes.
Transition action and guard notation

transition action

off hook / play dial tone


[valid subscriber]
Idle Active

on hook

guard condition
Nested States
• A state may be represented as nested
substates.
– In UML, substates are shown by nesting them
in a superstate box.
• A substate inherits the transitions of its
superstate.
– Allows succinct state machine diagrams.
Nested states

off hook / play dial tone

Active
[valid subscriber]
Idle

PlayingDialTone Talking
on h
ook

digit digit connected

complete
Dialing Connecting
State-Independent

• State-independent (modeless) — type of


object that always responds the same way
to an event.
• Ex if an object receives the message
“customer pressed the cancel button” or
“customer finished the transaction” , the
corresponding method will be Ejecting
card.
State-Dependent
• State-dependent (modal) — type of object
that reacts differently to events depending
on its state or mode.
• Ex for an “insert card” event the state will
be “reading card” whereas “enter PIN”
event the state will be “validating PIN”
Legal sequence of use case operations
Process Sale

WatingForSale makeNewSale EnteringItems

enterItem
endSale

authorized makeCashPayment WaitingForPayment

makeCreditPayment

AuthorizingPayment makeCheckPayment
More notations

Transition
action

complete/ glow indicator


Reading Reading
card valid card card

Guard
condition

The glow indicator denotes the


transition action and the valid card
denotes guard condition.
Nested states

• nested states are the states that occur


within the one super state.
• Ex Active state is a super state in which
the sub states display, reading card,
validating PIN are present.
• When the perform shutdown event
occurs the system is restored to idle to
active state.
Nested states
State machine model - ATM
Microwave cooking state diagram

You might also like