12B. Avoiding the Swamp: Planning


Planning your algorithms

Does an artist make a painting by standing up a canvas and painting? No. The first step is an idea of what the painting will convey. After that is a rough sketch, then a more detailed sketch. Finally, the artist paints on top of the detailed sketch.

Students are typically introduced to computer programming by having them sit in front of a computer and type something. That obviously gives them the idea that you write computer software by working on a computer. But that leaves out an important part of the picture.

Before you begin to type a function definition, work out the algorithm on paper. In class, you will see algorithms developed by drawing pictures of data structures and tables showing how loops work. Do that yourself! Do not start by sitting down and typing the program, hoping inspiration will come to you.

After the pictures and tables, sketch out the function definition. Then you are ready to type your function definition and test it.

Students who skip over planning tend to rely on guessing, since they have nothing to guide them. Guessing does not work. Students who rely on guessing will fail this course.