You are on page 1of 21

Design Methods

CT015-3-2 Version 1

Finite State Machine


Topics and Structure of the Lesson

• Finite State Machine Modeling


-Notations
-Relationships

CT015-3-2 Design Methods Finite State Machines Slide 2 of 21


Learning objectives

• At the end of this lecture, you should be


able to :
– Describe the elements in a state machine
diagram
– Describe the relationships in a state
machine diagram
– Create a state machine diagram

CT015-3-2 Design Methods Finite State Machines Slide 3 of 21


Keywords

• State
• Orthogonal

CT015-3-2 Design Methods Finite State Machines Slide 4 of 21


Finite State Machines

• Also referred to as state machine


• Finite state machines are used for
modeling the control and sequencing view
of a system or object.
• Notations used to define finite state
machines are the state transition,
triggering events and actions.

CT015-3-2 Design Methods Finite State Machines Slide 5 of 21


Finite State Machines

• Shows the behavior of one object of a


single class
– shows all possible states of this object
– shows how the object’s state changes as a
result of messages it receives

CT015-3-2 Design Methods Finite State Machines Slide 6 of 21


States
• State = set of values that describe an object (its
condition/situation) at a specific moment in time
•State is determined based on the attribute values

Account overdrafted

balance : Float
states
ok

CT015-3-2 Design Methods Finite State Machines Slide 7 of 21


State

• Actions: Work the system does in response


to events
– States can have entry, exit, and do
activities performed while in the state
• E.g.

CT015-3-2 Design Methods Finite State Machines Slide 8 of 21


Transitions

• A transition is the path taken during a


change of state from one state to the next
in response to a triggeringevent
• Guard condition: Optional condition to be
evaluated; if false, the transition is not taken

CT015-3-2 Design Methods Finite State Machines Slide 9 of 21


State Machines

• State transitions:
Possible paths the
system may take from
one state to another
• Triggering events:
Instantaneous events that
stimulate state transitions

CT015-3-2 Design Methods Finite State Machines Slide 10 of 21


Orthogonal States

• To model different views of the same


object’s state.
• Are composite states with two or more
regions within the state.
• The two orthogonal statecharts are shown
separated by dashed line

CT015-3-2 Design Methods Finite State Machines Slide 11 of 21


CT015-3-2 Design Methods Finite State Machines Slide 12 of 21
Choice Points

• Choice points realize a dynamic


conditional branch
– Outputs transitions, each with a guard
condition, one of which must be true.

CT015-3-2 Design Methods Finite State Machines Slide 13 of 21


Junctions
• Junctions realize a static conditional branch
– Can be used to split or join multiple transitions
– Guard conditions are evaluated before transitions

are fired
• If all guard conditions return false, then remain in the source

CT015-3-2 Design Methods Finite State Machines Slide 14 of 21


Example of state machine
diagram

CT015-3-2 Design Methods Finite State Machines Slide 15 of 21


Example of state machine
diagram

CT015-3-2 Design Methods Finite State Machines Slide 16 of 21


Example of state machine
diagram

CT015-3-2 Design Methods Finite State Machines Slide 17 of 21


Quick & Review Question

• Which model elements can have


associated state machine diagrams?
• In what cases would you use state
machine diagrams?
• What is a choice point?
• What is a junction?

CT015-3-2 Design Methods Finite State Machines Slide 18 of 21


Summary of Teaching points

• Finite State Machine Modeling


-Notations
-Relationships

CT015-3-2 Design Methods Finite State Machines Slide 19 of 21


Q&A

CT015-3-2 Design Methods Finite State Machines Slide 20 of 21


What We Will Cover Next

• Revision and Assignment


Discussion/Progress

CT015-3-2 Design Methods Finite State Machines Slide 21 of 21

You might also like