Embedding Scenario-based Modeling in Statecharts

Assaf Marron, Yotam Hacohen, David Harel, Andreas Mülder, Axel TerflothMoDELS (Workshops) 2018

Abstract

This paper introduces a novel integration of Scenario-Based Modeling (SBM) within the Statecharts visual formalism. By embedding SBM’s "request" and "block" event logic directly into hierarchical states, the authors create a modeling environment that is both visually intuitive and highly incremental. This hybrid approach allows developers to add new system requirements as orthogonal components without modifying existing logic, effectively bridging the gap between intra-object state transitions and inter-object coordination.

Introduction

Designing complex reactive systems—such as flight controllers or medical devices—presents significant challenges in coordinating multiple interacting components. Traditionally, engineers rely on two distinct formalisms: Statecharts and Scenario-Based Modeling (SBM). Statecharts excel at describing the internal logic of individual components through hierarchical states but often struggle with cross-cutting coordination. Conversely, SBM focuses on "scenarios" that align with human requirements and inter-object interactions but lacks the formal visual hierarchy of Statecharts.

This research addresses this gap by proposing an amalgamated formalism that combines the "best of both worlds." The authors developed a prototype by extending the open-source YAKINDU Statechart Tools (YSCT), introducing hierarchical event declarations and a modified execution engine.

The Amalgamated Formalism

The core technical contribution involves two primary shifts in the Statechart model. First, every state is extended with two new properties: a set of requested events (actions the state desires) and blocked events (actions the state forbids). Due to the hierarchical nature of Statecharts, the active set of requests and blocks at any moment is the union of those defined in all currently active states and their ancestors.

Second, the execution engine was modified to follow SBM-style logic. Instead of merely reacting to external triggers, the engine continuously evaluates all active states to find an event that is requested by at least one state and not blocked by any other. This allows orthogonal regions of a Statechart to synchronize and constrain each other dynamically.

HumanPilot statechart demonstrating the use of 'request' properties within hierarchical states.

Case Study: Rocket-Landing Simulator

To evaluate the approach, the authors implemented a Rocket-Landing Game. This simulator involves complex, multi-faceted requirements including gravity, manual pilot control, autopilot systems, physical boundaries (walls), and environmental adversaries like waves shifting the landing platform.

A key advantage of this hybrid model is how it handles exceptions and boundaries. For instance, preventing the rocket from moving through a wall does not require modifying the movement logic itself. Instead, a separate "Wall" statechart simply blocks the "MoveRight" event whenever the rocket's position coincides with the wall's boundary.

RightWall statechart demonstrating the 'block' property to prevent specific actions based on environmental conditions.

Results and Discussion

The prototype demonstrates that high levels of incrementality are achievable. New behaviors, such as an autopilot or an adversary, were added to the rocket simulator with minimal to no changes to the existing "basic" scenarios. Furthermore, the models are more succinct than traditional Statecharts because the "request/block" infrastructure handles coordination implicitly, removing the need to model every possible interaction explicitly.

The integration also provides better state-awareness for scenarios. In standard SBM, scenarios often require extra variables to track the system's overall state. Here, scenarios can naturally transition based on whether other components are in specific states (e.g., stopping the game if the rocket enters a 'Crashed' state). Additionally, "cold violations"—where a scenario is interrupted—become explicitly visible as transition arrows, improving auditability.

Conclusion and Future Work

While the current prototype successfully demonstrates the feasibility of embedding SBM in Statecharts, several areas for future work remain. These include full support for liveness properties (distinguishing "must" vs. "may" events), more sophisticated handling of time as a first-class citizen, and scaling the implementation to distributed systems. Empirical studies with professional engineers are also planned to validate the productivity gains of this approach in industrial settings.

Summary updated

BibTeX
@inproceedings{marron2018embedding,
  author = {Assaf Marron and Yotam Hacohen and David Harel and Andreas Mülder and Axel Terfloth},
  title = {{Embedding Scenario-based Modeling in Statecharts}},
  booktitle = {MoDELS (Workshops)},
  year = {2018},
}
Figure