A.J.Guttmann. Programming and Algorithms an Introduction,1977. Heinemann Educational Books Ltd. London.

The concept of efficiency itself has changed considerably over the last decade. Ten years ago, any discussion of efficiency was primarily concerned with questions of processor time and storage requirements. While these are certainly not negligible today, the cost of computer hardware has rapidly decreased, while manpower costs have increased. Thus questions of efficiency now tend to focus on the minimization of manpower costs. Programming courses should properly concentrate on stressing these aspects, as well as the methodology of writing programs in a manner that efficiently utilizes the programmer’s time. Such a methodology should result not only in readable, maintainable programs, but programs that require a mini­mum of debugging. It is difficult to overstress this last point, since it has been estimated that as much as 50 per cent of the programmer’s time has been spent on debugging programs.

In response to these changing requirements of program writing, a more systematic view of the process of computer programming has begun to emerge. The stage has not yet been reached — or even foreseen — where a set of rigid rules can be mechanically applied to any programming problems, resulting in a first-class program. Rather certain guidelines can be given, which, if intelligently followed, should result in better programs being produced. The process is not unlike that of writing a piece of prose. There exist the rigid rules of the written language - the syntax - that must be obeyed, but in addition there are generally accepted notions of style which can greatly facilitate the production of a piece of prose. Nevertheless, following these stylistic guidelines is not sufficient to turn the budding author into a Shakespeare.


 

 



Chapter 6.1 Introduction

In this chapter we will be looking at some aspects of the general problem of program writing. Unfortunately we cannot give a strict set of rules that will lead to a perfect program, but we can give guidelines for the design and construction of good programs These guidelines include the sequence of steps to be followed in program design and construction. Another aspect of program writing is the way in which certain operation: should be coded. Familiarity with these standard situations will usually lead to more efficient programs in terms of programmer’s time, computer time, and memory requirements.

As discussed in Chapter 1, the recommended philosophy in program design is the top-down approach, whereby the solution to the problem is developed in a sequence of steps, each of successively finer detail. By ‘the solution’ we mean all aspects of the solution, including the way in which the data is to be presented, the algorithm for solving the problem in the light of this form of data, and the details of the output from the program. Since these are interdependent, the only way a solution can be efficiently arrived at is by progressive refinement of each aspect. This philosophy is really just the application of the scientific method to the task of program writing.

Let us consider the creative and mechanical steps in writing a program, and then look at them in more detail. This then is a top-down approach to developing a top-down approach to program writing!

After a little reflection, it should be clear that the following six steps are involved it designing a program.

(1)

Generally formulate the problem to be solved.

(2)

Decide on the appropriate programming language.

(3)

Decide on the best method of solution, developing your solution by flowcharting by drawing decision tables, or by natural language formulation or a mixture of these representations.

(4)

Translate the result of part (3) into the desired programming language.

(5)

Test and correct the program.

(6)

Add final documentation to the working program.

This process is summarized in the flowchart (Figure 6.1).

Supplement this with hand calculations which can be compared with de-bugging output.

etc the documentation of your program.

(We will not consider the purely mechanical task of getting the program onto the desired input medium, such as cards or paper tape.) Each of these steps can be broken into finer steps, and at each stage a number of factors have to be borne in mind.

;