Sample Code For Students

Computer Science Teacher
Computer Science Teacher - Thoughts and Information from Alfred Thompson

Sample Code For Students

  • Comments 4

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.

[Edit: Fixed typo of Lego to Logo thanks to a comment from a reader.]
  • I think you meant "Logo" instead of "Lego."

  • Yep, I meant Logo. I've gone back and fixed it. Thanks!

  • I like this idea. I've done it before in Java classes. Give them some code and several "challenges": Change what the server says when the client connects to it. Put in your own graphics and sound. Make the questions come out faster. And in Python Pygame classes using the sample "Aliens" ("space invader") game: make the aliens go faster. Let yourself shoot 10 missiles at a time. Allow rapid firing.

    Now you have me thinking about how I might use this teaching method in my Scratch/Alice class today.

  • Getting people to think about different possibilities is always a goal. Let me know what you come up with Scratch/Alice stuff. I'm always interested.

Page 1 of 1 (4 items)