I also value having students trace code. Of course, if I just show students code and ask them what it evaluates to/prints when they are in their room, they can simply type it in and run it. That doesn't benefit them or force them to work on the skills I want them to develop. This post describes an idea I had in regards to this. If anyone happens to read this who writes CS educational tools, feel free to take the idea and implement it yourself. Part of the motivation for this idea came from the stack trace display in DrRacket.
The basic idea is that you have students indicate where the flow of control goes and possibly have them enter values for variables along the way. The goal is to force them to actually demonstrate that they followed the code. That way, even if they do type it in and run it, they still have to think things through.
The figure below shows a mock-up of what the simplest interface might look like. The instructor would provide the code and the student has to click on each line in the order that control passes through them. Not only does this force the student to think through what is happening, it can be verified automatically so that students can be told if they have the proper trace without taking additional instructor time. That is essential if you actually want to use this to force students to do things in a real setting.
This would work for recursive functions too. As shown here, you have a table with a large column for each variable/name. You could also have separate tables for the different stack frames. I can also picture a more dynamic representation where there is only one row drawn for each stack frame, and the program records the values in that for each step in the computation. Then the student or someone else looking at what the student did could select an arrow to see the value of the stack frame at that time.
Does anyone know of tools like this? Would anyone be interested in having something like this? Personally, I really like to get students to trace through code and I can't do nearly enough of it. I feel that a tool like this could be very beneficial in the CS1 setting and even in some parts of CS2 and Data Structures.
No comments:
Post a Comment