L.A.W Home Page. All parts of the software which has been developed in the previous chapters were designed as sequences of instructions. The sequences were expressed in the program structure charts and in the derived source code. If this was the only method available to instruct a computer, programming would be impossible. Selection involves instructing the computer to decide between two, or more, possible courses of action.
Iteration involves instructing the computer to repeat a sequence of actions a number of times.
Although the previous chapters have emphasised the construction of programs from a number of separately compiled program modules, in order to illustrate the design, construction and use of software components which use selection and iteration, a simpler form of construction where the subprograms of the program procedure are defined in the same source code file will be used. Although this technique is more convenient for small simple specifications, it should be remembered that the technique is not scalable to more realistic specifications and that it limits the potential reusability of subprograms. For these, and for other reasons, these technique should not be relied upon and the construction of applications from separate modules should be practised. This chapter will introduce the design and use of selection, the following chapter will introduce iteration. These facilities will then be used extensively throughout the rest of the book.