Leigh Ann Sudol has an interesting post titled The Beauty and Elegance of Computer SCIENCE. In it she talks about what makes a good example or exercise and the difference between an exercise and an example. One thing she leaves out, or perhaps just doesn’t spell out, is that good examples and exercises should take advantage of the power of a computer. I first heard that in a workshop taught by Mark Stehlik (who is on the faculty of Carnegie Mellon where Leigh Ann is currently a grad student). Mark pointed out that if you give a student a piece of code that does something they can do in short order with a calculator or worse still in their head their thought is going to be “well what use is that?” And they’d be right.
A good exercise/example should really require a computer. Some years ago I replaced the simple “convert Fahrenheit to centigrade” example that I used to introduce writing formulas in a programming language to an example where the formula was tied to a slider.
As an example it takes me a few minutes to set up which I would do before class. As an exercise it might be too easy for students to get hung up in the user interface so I might not use it. If I did I would give them the UI pre-built so they could focus on the formula and understanding how the assignment statements worked. For teachers who avoid GUI programming, and I know many who do, the possibility exists for creating a conversion table. Though the problem with that is that it requires loops so this would have to be saved until later. But the beuty here is that the GUI makes is so easy to try multiple values in seconds that students have more fun with it right away.
Which gets to the next big thing in Leigh Ann’s post – the beauty of computer science. Examples give an instructor a chance to go beyond the specific case and explore the wider world of the concepts involved. One of my favorite unexpected, unplanned moments was once when I was teaching loops in C++. Somehow I got off on the tangent of showing loop syntax in several other languages. I think that besides C++, I talked about FORTRAN, COBOL, Assembly language and of course Visual Basic. C# and Java were close enough that I seem to remember talking about them as well. It was short but let us really discuss what a loop was all about. What are its pieces and why does it work – beyond the syntax of a specific language.
Students later told me that they got a lot out of that lecture and that they found it helpful later on in their academic careers. Wow, who knew! But that is what can happen with a good example. It can start discussion and show off a lot more (and more interesting things) than just syntax. It can open minds to the possibilities. We really need to think about the examples we use more often then I think most of us do. I know I need to think more about them.