Next: Reserved words and Up: No Title Previous: On arbitrariness and

Layout and indentation

Findlay &Watt have adopted a convention on laying out programs on the page/screen which is typical of a style which most programmers in the world follow. This will be our ``house style''.

The basic features make the structure of the program very clear to the (practised) eye. They include:

Study the examples of programs throughout Findlay &Watt. There is a basic statement of their policy on page 32.

Some programmers prefer to indent the sequence of statements between begin and end by a further two spaces. Findlay &Watt do not do this, so we will leave it as an individual freedom - but be consistent.

Erratic indentation is necessarily inconsistent, and so loses marks.

Blank lines in between procedure declarations and in between major sections of program are also helpful. But do not put a blank line between every line of the program.

On a related topic, think about the fact that the programmer &reader of a program will be reading it on a screen or on a paper print-out. A well arranged program will minimize the amount of scanning back and forth/page turning, and so make the program easier to read and absorb. To this end: a good guide to the maximum size for a procedure is ``less than a page'' (or, on the screen, ``less than a large windowful'' - small windows really are too small). Also, grouping related procedures close together will improve what is often called the ``locality'' of a program.



Next: Reserved words and Up: No Title Previous: On arbitrariness and


Simon Jones (sbj@cs.stir.ac.uk)