next up previous
Next: Outline of the course Up: Description of the course Previous: Description of the course

Modularity and stepwise refinement

The idea underlying modularity is, in short, the decomposition of a complicated task into a group of small independent subtasks. Not only is handling the smaller problems usually easier, but this method is also helpful in attaining a better insight into the original problem. Also, the comprehension of a long and complicated algorithm may become easier by considering its smaller components.

The modular structure of an algorithm eases the reading and analyzing of it, and also proving its correctness. Debugging will involve only local corrections, that is, correcting one particular module will not necessarily lead to changes in other modules.

As for stepwise refinement and top-down design, let us first comment that despite the fact that we will here advocate a top-down design method, sometimes in real world problems a bottom-up approach is needed.

The technique of stepwise refinement helps to gradually develop an algorithm or a program, in a sequence of steps. The first step is a top design of the solution, which introduces the group of subtasks the algorithm has to handle. In the next step one or more of the given subtasks is decomposed into more detailed instructions. In each of the next steps one or more instructions are decomposed into more detailed ones. This refinement process terminates when one reaches what has been defined as elementary instructions.

It is known that novice programmers who don't use top-down design and stepwise refinement may find themselves referring directly to elementary instructions, resulting in poorly-styled programs, unreadable and difficult to maintain. As mentioned in [SFA], developing algorithms this way is like going on a journey without planning its course, stopping after each step in order to decide where to go next. The way is lost time and again, backtracking and starting all over is inevitable, and the destination reached may very well not be the one initially intended. Using the top-down and stepwise refinement method when designing algorithms is like planning the journey by setting interim goals, and working out a short and safe way.

It should be noted that the top-down and stepwise refinement techniques are, in fact, general strategies for problem solving that are applicable in many fields, including solving complicated mathematical problems or even teaching complicated mathematical proofs[LER].

To conclude, decomposition and stepwise refinement can effectively draw the students' attention to the general structure of the algorithm, and turn the programming itself(translating the algorithm into the language of a certain executer) into questions of secondary importance. The student discovers that there is no need to change the structure upon transition from one executer to another. A well structured algorithm will fit into almost every new environment.


next up previous
Next: Outline of the course Up: Description of the course Previous: Description of the course
2004-01-06