Ever since I read those papers on the Rainfall program (How Hard Is That Programming Problem?) I’ve been thinking about patterns in problem solving and programming. There are many of these types of patterns in programming but most of us learn them through experience.
The Rainfall problem is one example. It’s basically a counting and totaling loop that handles exceptions. Anyone who has done one of those (or maybe two if they are like me) probably sees that pattern as soon as they read or hear the problem statement. It’s new to beginners though.
One of my favorite patterns (much more complicated for beginners to see) has to do with avoiding special cases for boundary conditions. Take for example the lights out project (Taking Things To Another Level ) it involves checking the squares above, below, to the left, and to the right of a box in a 5 by 5 grid. Beginners tend to see that as calling for special cases for the corners and edges. Experienced programmers create an invisible row above and below and an invisible column to the left and right of the visible grid which allows all boxes to be checked the same way. It’s a pattern many of us have seen before.
After a while I think most of us don’t even consciously think “oh that is a pattern I have seen before” but we just go with it. Of course there are far too many patterns to teach all of them in a single semester (or single life time I suspect.)
lately I have been asking myself “what are the most common patterns I can think of and how to I create projects to give students experience with them?” And more than that, how can I get them to recognize those patterns in the future? I can’t assign enough projects so I think we’ll be reading some code. Maybe playing with Parsons Problems. But definitely I need to have students read more code.
Do you teach patters explicitly or just implicitly? What patterns do you see as most important for beginners to learn?
No comments:
Post a Comment