Last week, I discussed one of the downsides of students being taught to think algorithmically, even if they absorb it all. Unfortunately, just because students can pass an introduction to programming course doesn’t mean they have any understanding of code that they or anyone else has written. Whenever I teach a course, I make a point to mention cargo cult programming and warn students not to fall into that trap.
When people employ cargo cult programming, they don’t write code; instead, they plop down patterns in various combinations until they complete the task at hand (if ever). If you’re thinking that this type of “programming” should be caught on a test and the student failed, that works well in theory. However, with the way we award or deduct marks, a broken solution still gets part marks — often enough to pass and sometimes even “earn” quite a high score.
“‘Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?’ In one case a member of the Upper, and in the other a member of the Lower House put this question. I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question” — Charles Babbage
Cargo cult programmers are readily exposed when they are taught about recursion. Some students have difficulty with recursion itself but cargo cult programmers have the added difficulty of not understanding what their code is doing. I’ve found cargo cult programming can be easily detected early on when I ask a student what a particular section of code does (e.g., the input/output performed and/or changes in values of variables). The cargo cult programmers will tell me what the code is “supposed” to do and seem unable to fathom the distinction between what the code does and what they think it does. Last year, I had a student in a tutorial who was very vocal in his insistence that a particular piece of code produced a certain result because he’d seen it in class. Classic cargo cult.
By requiring students to pass a programming course to complete an undergraduate degree, are we doing them any favours if they don’t learn algorithmic thinking and algorithms remain opaque to them? It takes quite a bit of work to teach a class to program, but if we don’t teach them how to think algorithmically, is it worth it? We may have shown students what good fishing technique looks like and some will figure out that this is to be done in places teeming with fish. Others, however, will repeat the net-casting action in the depths of the New York sewer system and instead catch alligators that will come back to bite them. If not programming, where would educational efforts be better directed differently? Perhaps there’s an easier way to teach people to think algorithmically than by teaching them to program.