Scenario-based programming (SBP) allows developers to specify system behavior through interactions between objects, typically using sequence diagrams. However, traditional SBP often treats objects as flat, independent entities, failing to capture the hierarchical "part-of" relationships common in modern object-oriented design (OOD). This paper introduces "LSC-trees" to bridge this gap, enabling the formal decomposition of high-level interactions into detailed sub-scenarios while preserving the rigorous semantics of Live Sequence Charts (LSC).
The Challenge of Hierarchical Objects
In real-world software engineering, objects are rarely flat. For instance, a "View" object in a Model-View-Controller (MVC) architecture might be composed of an "InputPane" and a "MessagePane." Before this research, there was no formal, executable method to handle these relationships within scenario-based languages. The challenge was both syntactic—how to represent a lifeline being broken down—and semantic—how to ensure that mandatory ("hot") or optional ("cold") interactions at a high level are correctly maintained when zooming into component behaviors.
LSC-trees and the Composition Algorithm
The authors propose LSC-trees, a hierarchical structure where a lifeline in a "parent" scenario can be decomposed into a "part-LSC." This allows for a decentralized design where high-level protocols are defined via abstract interfaces, and detailed behaviors are "plugged in" as subtrees.
To make these hierarchies executable, the researchers developed a composition algorithm that recursively "flattens" the trees. This algorithm merges part-LSCs into their parents by matching corresponding events and interleaving partial orders of messages. Crucially, the authors defined refined modal rules to ensure that the "hot" (universal) and "cold" (existential) nature of interactions is preserved. For example, if a high-level event is mandatory, its refinement must also remain mandatory to prevent logic "leaks."
Key Results and Implementation
The approach was integrated into the S2A compiler, translating LSCs into AspectJ code for execution in Java applications. The composition algorithm proved efficient, running in $O(nk)$ time, where $n$ is the number of LSC nodes and $k$ is the maximum number of events per node.
The framework's modularity was demonstrated using a Phone Book application. By simply replacing a subtree in the LSC-tree, the authors could swap out a GUI implementation (e.g., replacing a PhoneBookView with an EnhancedView) without altering the top-level requirements. This "symbolic binding" allows the execution engine to coordinate behavior across different levels of abstraction seamlessly.
Insights and Future Directions
A critical insight from this work is the importance of trace containment. Simply matching events is insufficient; specific rules must govern how "minimal events" (scenario triggers) are handled across the hierarchy to ensure the composed system satisfies original requirements.
While the tools for composition are now established, limitations remain. Current algorithms may make non-deterministic choices if a high-level event corresponds to multiple sub-events, requiring designers to manually mark correspondences. Future work will focus on supporting "co-region" operators for unordered events and developing design methodologies to guide engineers on when and how to effectively decompose scenarios.
Summary updated