1 / 12

Enhancing Program Comprehension with recovered State Models

Enhancing Program Comprehension with recovered State Models. Stéphane S. Somé Timothy C. Lethbridge SITE, University of Ottawa. State Transition Models can help program comprehension. High-level behavior models Capture design decisions Mapped to code

adominic
Download Presentation

Enhancing Program Comprehension with recovered State Models

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  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. 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. 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. Procedural idioms (2) void eventB() { switch(State) { case state1: b_1(); State = state2; break; case state2: b_2(); State = state1; break; default: /* error */ exit(0); } } void eventA() { switch(State) { case state1: a_1(); break; case state2: a_2(); break; default: /* error */ exit(0); } }

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

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

  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. State Transition Graph • States defined as <variable,value> • Transitions • change from a state to another • events correspond to control structure conditions

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

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

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

More Related