170 likes | 305 Views
Abstraction and Dynamic Analysis for the Reconstruction of Scenario Diagrams. Bas Cornelissen Leon Moonen Arie van Deursen. Introduction. Scenario event from the user’s perspective Scenario diagram UML sequence diagram at the scenario level Long-term goal
E N D
Abstraction and Dynamic Analysis for the Reconstruction of Scenario Diagrams Bas Cornelissen Leon Moonen Arie van Deursen
Introduction • Scenario • event from the user’s perspective • Scenario diagram • UML sequence diagram at the scenario level • Long-term goal • e.g., conformance checking, design pattern detection, architecture reconstruction (?)
Challenges • Static analysis • source code • independent of input • potentially covers all object interactions • Dynamic analysis • execution traces • scenario- and input-driven • polymorphism: detection of late binding • merely applicable in “complete”, executable systems
Challenges • Abstraction • typically, initial diagrams: • are too large • show too many details • contain uninteresting interactions • this calls for abstraction mechanisms • omit irrelevant messages and/or objects • allow user to choose the level of detail
Method • Reconstruction of scenario diagrams using JUnit and AspectJ • Scenario determination • Producing an execution trace • Abstraction • Visualization
Running example • Pacman • 25 Java classes • GUI • Large traces • Polymorphism
1. Scenario determination • JUnit testcase • basically a use case • contains one or more scenarios public class PacmanTest extends TestCase { public PacmanTest(String arg0) { super(arg0); } public void testTopLevelAlphaOmega() throws InterruptedException { Pacman p = new Pacman(); p.start(); System.out.println("SCENARIO START"); p.up(); System.out.println("SCENARIO END"); p.quit(); p.exit(); } }
2. Producing a trace • Aspect for tracing methods and constructors • exclusion of certain classes and/or methods • distinction between run-time objects • at call sites, log: • method/constructor ID • caller + object ID • callee + object ID • method/constructor signature • actual parameters METH 533: Pacman [1] :: Engine [2] :: public synchronized void Engine.movePlayer(int, int) :: 0, -1
3. Abstraction • Compression • summarize recurring messages and patterns • requires pattern recognition • post-mortem • Pruning • hide uninteresting interactions (and objects) • define minimum and maximum stack depths • both at the tracing and the visualization stage
4. Visualization • GNU plotutils package • pic2plot • library containing pic macros for seq. diagrams • Perl script to create pic programs from traces object(Pacman1,"Pacman1"); object(Engine2,"Engine2"); object(Game3,"Game3"); ... step(); active(Pacman1); message(Pacman1,Engine2,"movePlayer(int, int)"); active(Engine2); message(Engine2,Engine2,"inPlayingState()"); message(Engine2,Game3,"initialized()"); ...
Example (1) • Compression
Example (2) • Pruning
Conclusions (1) • JUnit testcases • enable scenario diagram reconstruction for both complete systems and incomplete systems/modules • AspectJ • flexible: allows for (not) tracing specific components and/or messages • distinguishes between run-time objects
Conclusions (2) • Effective abstraction mechanisms • human-readable, high-level model is easily obtained • though omission of messages at deep stacklevels may be infeasible • Better visualization is needed • interactive • e.g., zooming, expanding
Questions Fire at will!