Presentation is loading. Please wait.

Presentation is loading. Please wait.

The Visual Debugger for Recursive Functions By Charles Nogee Advisor: Dr. Bonomo.

Similar presentations


Presentation on theme: "The Visual Debugger for Recursive Functions By Charles Nogee Advisor: Dr. Bonomo."— Presentation transcript:

1

2 The Visual Debugger for Recursive Functions By Charles Nogee Advisor: Dr. Bonomo

3 Introduction  Goal:  A visual representation of recursive functions  Uses:  Pedagogical  Debugging

4 Debugging Steps 1. Recognize error 2. Find the error in the code 3. Determine how that spot relates to program

5 Debugger Evolution  Command Line driven  Text for the names and values of variables  Keyboard Input/Text Output  Various breakpoints  Single Stepping  Graphic User Interface (GUI)  Show the code executing  Reveal values of variables by clicking on them  Still just names and values of variables

6 Visualization  Sight provides the most understanding  For Effective Visualization (Stasko, et al., 93)  Include detailed text instructions  Link with instructional goals  Perform user testing  Include rewind/replay functions

7 Recursion  A recursive function is one that can call itself  Breaks large problems into small problems  Base cases  Taught early in computer science courses  Taught at Westminster in CS 152, the second CS course

8 Factorial Example  n!=n*(n-1)*(n-2)*…*3*2*1  In recursive form  n!=1 if n=1  n!=n*(n-1)! if n>1  In Computer Code Factorial(n){ If(n==1) Return 1; else return n*factorial(n-1); }

9 Factorial Example Factorial(4) 4*Factorial(3)3*Factorial(2)2*Factorial(1) 1 2*123*264*624

10 Typical problems using recursion  Missing, incorrect, or too exclusive base case  Factorial can only work for nonnegative integers  Exorbitant and repetitive branching

11 The Recursive Debugger  Goal-Visually depict recursive functions  Use of tree structure  Downward branching  Outward branching  Function Box  Parameters, Return values, Received values

12 RecursionDebugger Class  Software to create, update, and maintain display window  Evolved over 2 semesters  Command line based  GUI based  Requires tags to be inserted in user’s code

13 Factorial Before Tags added  public class Fact{  public static void main(String args[]){  System.out.println(fact(Integer.parseInt(args[0])));}  public static int fact(int n){  if (n==1){  return 1;  }  else{  int val=fact(n-1);  return (n*val);  }}}

14 Factorial with Tags  public class Fact{  public static RecursionDebugger hp=new RecursionDebugger("fact", false);  public static void main(String args[]){  System.out.println(fact(Integer.parseInt(args[0])));}  public static int fact(int n){  hp.createNewBox();  hp.setNextParameter(""+n, "n");  hp.endParameters();  if (n==1){ hp.changeCurrentAndReturn("1");  return 1;  }  else{ int val=fact(n-1);  hp.updateReceived(val+"");  hp.changeCurrentAndReturn((n*val)+"");  return (n*val);  }}}

15 Half Time

16 Debugger Window

17 Example Displays-Factorial

18 Example Displays-N Queens

19 Drawing the Tree  when endParameters() and changeCurrentAndReturn() are called  Each box’s placement is relative to parent or sibling  Each box contains two displacement fields  transx  transy

20 Updating Translation

21 Updating Translation 2

22 Updating Translation 3

23 Updating Translation 4

24 This is where you do the demonstration, Chuck

25 Future Possibilities  Program Rewind  Other language Implementations  Global variables  Multiple recursive functions  Collapsible tree  Automatic Tag Insertion

26 Conclusions  Met our design goals  Works for a wide variety of recursive functions  Visualization criteria  Include detailed text instructions  Link with instructional goals

27 The End “Hail to the King, baby.” “Good, bad, I’m the guy with the gun.” “But in my own way, I am king.” “Gimme some sugar, baby.”


Download ppt "The Visual Debugger for Recursive Functions By Charles Nogee Advisor: Dr. Bonomo."

Similar presentations


Ads by Google