WEEK 9 UML State Transition Machines

Brunel University London Software Development and Management

  • Course Title: CS2002

  • Instructor: Dr. Rumyana Neykova

  • Contact: Rumyana.neykova@brunel.ac.uk

State Transition Machines

  • Diagram representation of states and transitions.

    • occupy() Method: Changes the state to occupied.

    • release() Method: Changes the state to free.

Literature Reference

  • Textbook: UML @ Classroom: An Introduction to Object-Oriented Modeling

    • Authors: Martina Seidl, Marion Scholz, Christian Huemer, Gerti Kappel

    • Publisher: Springer Publishing, 2015

    • ISBN: 3319127411

  • Topics Covered:

    • Use Case Diagram

    • Structure Modeling

    • State Machine Diagram

    • Sequence Diagram

    • Activity Diagram

Outline of Content

  1. Introduction

  2. States

  3. Transitions

  4. Types of Events

  5. Types of States

  6. Entry and Exit Points

UML Diagram Types

  • Structural Diagrams:

    • Classes, Objects, Packages, Components

  • Behavioral Diagrams:

    • State Machine, Use Case, Sequence, Activity Diagrams

Introduction to State Machine Diagrams

  • Definition: Models the states of a system or object.

  • Functionality:

    • Shows possible states

    • Illustrates state transitions via events

    • Describes system behavior in each state

  • Example: Lecture hall object states.

Example: Lecture Hall Class

  • Class Structure:

    class LectureHall {
        private boolean free;
        public void occupy() { free=false; }
        public void release() { free=true; }
    }

Digital Clock Example

  • Clock Functionality:

    • Methods: set(), inc()

    • Entry Activities: beep on entry, show current time.

State Activities

  • Entry Activity: Action performed when entering a state.

  • Do Activity: Action performed during the state.

  • Exit Activity: Action performed when exiting the state.

  • Deferrable Trigger: Events that remain in the event pool if they do not trigger a transition.

State Definitions

  • States: Nodes representing active conditions of an object.

    • Activity Types:

      • entry: Executed upon entering a state.

      • exit: Executed upon exiting a state.

      • do: Executed while active in the state.

Transitions

  • Definition: Change from one state to another.

  • Components:

    • Source State

    • Target State

    • Event Trigger

    • Guard Condition

    • Activities Executed During Transition

Transition Syntax

  • Event (Trigger): Stimulus initiating a transition.

  • Guard (Condition): Boolean expression that must be true to proceed with the transition.

  • Activity (Effect): Actions performed as a result of the transition.

Transition Types

  • Internal Transition: Remains in current state while executing actions.

  • External Transition: Leaves current state to enter a different state while executing actions.

Sequence of Activity Executions

  • Scenario: Evaluating variable 'x' during transitions between states.

Example: Registration Status

  • States: Not registered, registered.

  • Transitions: Registration potential, withdrawal options.

Event Types

  • Signal Event: Triggered by receiving a signal.

  • Call Event: Triggered by operation calls.

  • Time Event: Based on relative or absolute timing.

Change Event vs. Guard

  • Change Event: Checked continuously for condition changes.

  • Guard: Checked only when an event occurs.

Initial State

  • Definition: Starting point in a state machine; cannot stay in this state.

Final State and Terminate Node

  • Final State: Represents the logical end of the state's sequence.

  • Terminate Node: Ends the state machine and ceases object existence.

Decision Node

  • Functionality: Models alternative transitions based on conditions.

Parallelization and Synchronization Node

  • Parallelization Node: Splits control flow into multiple paths.

  • Synchronization Node: Merges multiple flows back into one.

Summary of State Machine Elements

  1. State: Defined period of object life during which activities can occur.

  2. Transition: Movement from one state to another.

  3. Initial State: Start of the state machine.

  4. Final State: Conclusion of the state machine.

  5. Terminate Node: Marks the end of the object's lifecycle.