One of the key reasons behind the case study in the Advanced Placement Computer Science curriculum is to give students some experience modifying an existing piece of code. In this case the case study is also a fairly large (by school project standards) piece of code so there is lots more that students can learn from it. There is specific value is just having students read a good hunk of code written by someone who really knows how to write code. I was recently reminded of how smaller pieces of code can be useful as well.
Last week I read a post on Programming Turtles as in the Logo sort of turtles written by “Rich Skyline.” One of the things he is doing is providing a working program for his students and inserting a number of comments that suggest things they can experiment with. For example a comment might suggest that students try different variable settings. Rich provides several samples and encourages his students to learn by tinkering. I really like this idea.
I can think of several things that would be useful. Take nested loops as an example. Have students try reversing the order (use the inner loop as the outer loop) – probably more interesting when the terminating values are very different. Graphic programs like the random turtle Rich blogs about are always interesting to students. One could also give students some code that pastes disks where the user clicks and ask them to modify the program in some way to made the disks move about the screen. Leave the algorithm up in the air to see what students come up with.
A lot of students naturally love to tinker but others want to have a script laid out for them. Comments with suggestions of things to try, even if they do not suggest actual values to change, allow the latter students to get involved more comfortably. They will still have to read through the code and they will still learn by manipulating the code but they will not be pushed too far beyond their comfort level (hopefully). And with any luck at all this will be a confidence builder to help them experiment more broadly. The natural tinkerers will just fly through the sample suggestions and go their own way. In the right environment (a louder classroom than some teachers are comfortable) they will share their ideas with others and a lot of valuable peer teaching may just break out. And that is usually a very good thing.