state diagrams n.
Skip this Video
Download Presentation
State Diagrams

Loading in 2 Seconds...

play fullscreen
1 / 17

State Diagrams - PowerPoint PPT Presentation

  • Uploaded on

State Diagrams. What state are we in?. Introduction. What are the two main parts of a computer program? Data Algorithms We have previously emphasized how real-world information can be turned into data . How processing functions can be described with activity diagrams

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'State Diagrams' - said

Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
state diagrams
State Diagrams

What state are we in?

  • What are the two main parts of a computer program?
    • Data
    • Algorithms
  • We have previously emphasized
    • how real-world information can be turned into data.
    • How processing functions can be described with activity diagrams
  • We will now describe how the data might change when processed
object oriented programming
Object Oriented Programming
  • Object-Oriented programming seeks to solve a problem using data models taken from the problem domain.
  • Problem domain: the concepts and elements of the problem that is being solved.
    • An Object is simply a "thing" in the problem domain
  • When designing software, a programmer will listen to the problem description and then identify the objects in the domain.
object oriented programming1
Object Oriented Programming

A programmer is asked to write a program that will manage a persons DVD collection. The software should be able to search by actor or movie title or year or rating. What are the objects?

A programmer is asked to write a flight simulator. The simulator shows a cockpit display to the user as the plane approaches a landing strip. What are the objects?

A programmer is asked to write a web site identical to Facebook. What are the objects?

more about objects
More about Objects

Example: Radio

What is the state?

What is the behavior?

  • An Object is a model of some thing.
    • An object has state (attribute data)
    • An object has behavior (actions it can take)
more about objects1
More about Objects
  • We might say that the state includes:
    • Station (some number)
    • Power (on/off)
    • Band (AM/FM)
    • Volume (some number)
  • We might say that the behaviors include:
    • Select the station
    • Turn on/off
    • Switch band
    • Volume up/down
objects change over time
Objects Change Over Time
  • Consider a program that allows users to control a virtual radio. When the software first starts, what are the values of the attributes?
    • Station, Power, Band, Volume
  • The user then does the following with the program:
    • The user turns on the radio
    • The user selects channel 98.9
    • The user turns up the volume
  • What are the values of the attributes now?
    • Station, Power, Band, Volume
  • The point is, the values of the attributes change over time.
the state of an object
The State of an Object
  • The State of an Object is a snapshot of the attribute values at one moment in time.
  • Recall the radio example. The start state is something like:
    • {Station:89, Power:Off, Band:FM, Volume:0}
  • A series of state changes then follow:
    • {Station:89, Power:On, Band:FM, Volume:0}
    • {Station:98.9, Power:Off, Band:FM, Volume:0}
    • {Station:89, Power:Off, Band:FM, Volume:1}
state diagrams1
State Diagrams
  • An activity diagram depicts the actions and their order when processing data
  • State diagrams depict how objects might change when processed.
  • Consider withdrawing money from an ATM:
    • State might involve: Checking, Approving, Rejecting.
    • Activities might involve: Insert Card, Enter PIN, Check balance, select withdraw, enter amount, take money, take card.
uml state diagrams
UML State Diagrams

the notation

a state

a transition from one state to another

start state

final state

Part of the Unified Modeling Language

Represents how objects are affected by processing activities



1st Grade

2nd Grade

3rd Grade

4th Grade


6th Grade

Example: Elementary School

Consider representing a student as a software object.

what causes transitions
What causes Transitions



1st Grade

fails standards

satisfies matriculation standards

potential events in software

• a user’s action

• triggered by another object

• a timed event

traffic light
Traffic Light
  • What might the states of a traffic light be?
    • red / green / yellow / others?
  • What events cause a transition?
    • elapsed time
    • time of day
    • arrival of car
    • power outage

at 2 a.m.

after 10 sec.






at 6 a.m.


car arrives

after 5 sec.

north/south car arrives

+ 2 sec. delay

more notation

Machine Operating Safely

state name

entry / start motor

exit / stop motor


do / display warning light

More Notation

Activities can be included within states.

Activities can be triggered when entering/exiting/in.

entry -- activity upon incoming transition

exit -- activity upon outgoing transition

do -- continuous activity within state


1st Operand

click digit (0 - 9)

entry / oprnd1  0

do / display oprnd1

click digit (0 - 9)

1st Operand More Digits

click digit (0 - 9)

click C

entry / oprnd1  oprnd1*10 + digit

do / display oprnd1

click operator (+, -, *, /)

click C

2nd Operand

entry / op  operator; oprnd2 0

do / display oprnd2

Calculate Result

click digit (0 - 9)

click digit (0 - 9)

entry / result  oprnd1 op oprnd2;

oprnd1  0

do / display result

2nd Operand More Digits

click C

click =

entry / oprnd2  oprnd2*10 + digit

do / display oprnd2

Example - Calculator


employee recommendation

applicant inquiry

applicant inquiry

applicant inquiry

Initial Stage

Person of Interest

applicant inquiry

entry / create file;

send application

entry / create file; send application;

respond to inquiry

Awaiting Application

Offer Pending


incomplete app

Still Awaiting

entry / respond to inquiry

entry / send offer

app complete

entry / return application

app complete


incomplete app

Application Complete

entry / send app to supervisors

super requests interview

super requests





Interview Pending

entry / schedule interview

exit / conduct interview


all supers reject

super says hire



No Hire


offer rejected

entry / send rejection

Example Get a Job!