meta data for this page

Modeling with State Machines, CSPA Exercise

Summary of state machine


  • Entity – Interacting entity with inputs and outputs, where state machine is controlling messaging logic.
  • States
    • Start state and End state
  • Input events (incoming messages to entity)
  • Transitions (how states are changing)
  • Output events or actions (what is happening in entity due input)
  • Interface – set of defined input events (messages) the entity is going to get


  • State machine as table (matrix) – is good to present coverage of inputs
  • State machine as graph (diagram) – is good to visualize the transition logic

Design steps (usually)

  • Find out related entities and define entity to model behaviour as state machine
  • Find out interfaces and messages in it the entity is going to get as input
  • Think and find out the states entity could be
  • Think transitions and actions along entity behaviour, remember start end end states (or declarations)

Task A

Model a vending machine. Machine takes money from user and serves drinks like Kola, Vissy, Jaffa or Muumi and also return change coins to user.

Give table and graph presentations of state machine(s).