Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Enhancing Program Comprehension with recovered State Models Stéphane S. Somé Timothy C. Lethbridge SITE, University of Ottawa.

Similar presentations


Presentation on theme: "1 Enhancing Program Comprehension with recovered State Models Stéphane S. Somé Timothy C. Lethbridge SITE, University of Ottawa."— Presentation transcript:

1 1 Enhancing Program Comprehension with recovered State Models Stéphane S. Somé Timothy C. Lethbridge SITE, University of Ottawa

2 2 State Transition Models can help program comprehension High-level behavior models Capture design decisions Mapped to code Strong connection between resulting code and state model Highlighted by use of state implementation idioms Problem: what if the original state model is lost or has-been altered

3 3 State implementation idioms Non-procedural languages Based on goto Procedural (non-OO) languages Based on control structures (if, switch, …) Table lookup Object-oriented languages Dynamic binding

4 4 Procedural idioms (1) void strans() { …. State = state1; /* initial state */ while(1) { switch(event) { case eventA: if (State == state1) a_1(); else a_2(); break; case eventB: if (State == state1) { b_1(); State = state2; …. } State variable definition change of a state variable

5 5 Procedural idioms (2) void eventA() { switch(State) { case state1: a_1(); break; case state2: a_2(); break; default: /* error */ exit(0); } void eventB() { switch(State) { case state1: b_1(); State = state2; break; case state2: b_2(); State = state1; break; default: /* error */ exit(0); }

6 6 State Model Recovery Process State Model Implementation Specification Specifies how state model implemented State Variable Used Routines (and source files) Idiom

7 7 Statement Tree Abstraction of parse tree with relevant information only Provide code layout Useful for dealing with statements affecting flow of execution

8 8 State Variable Definition Graph (SVDG) void strans() { (5) State = state1; while(1) { switch(event) { case eventA: if (State == state1) a_1(); else a_2(); break; case eventB: if (State == state1) { b_1(); (20) State = state2; …. } captures state variables control flow

9 9 State Transition Graph States defined as Transitions change from a state to another events correspond to control structure conditions

10 10 Multiple routines (1) Generate partial models (2) combine

11 11 SRecover Recovers state models given state implementation specifications How to find a Specification ? Traditional code exploration

12 12 Conclusion Supporting additional patterns table based implementation OO state patterns Dealing with multiple state variables Integration with code exploration tools


Download ppt "1 Enhancing Program Comprehension with recovered State Models Stéphane S. Somé Timothy C. Lethbridge SITE, University of Ottawa."

Similar presentations


Ads by Google