Home About

On Procedure Design

A procedure can be seen as a pattern for the local evolution of a computational process. A procedure embodies the rules that enforce the evolution of a process, its consumption of computing space and time. Also, a procedure contains a set of coherent statements that rely on one another and together achieve the specific goal intended by the procedure. To design a procedure, we should consider the sets of values it receives as input and the set of values it should return as output. A procedure receives input, manipulates the input and returns suitable output. Hence, to design and implement a procedure, we should pay particular attention to values received and returned as output.

Steps for designing a procedure, with an example

Designing a procedure called list-length using scheme

State the contract of the procedure

Identify the input and output, I/O. list-length takes as input a scheme list, and returns an integer which is the length of the list.

Sepcify the usage of the procedure

(list-length l) –> Int

Investigate the nature of the input

Express the nature of the input in a useful language.

List ::= () (Value . List)

A list, in scheme, is either empty or it is made of 2 parts:

Consider each possible existential form of the list, and construct a procedural handler for it. This is analogous to writing web applications, where the nature of requests are investigated, requests routes constructed, and request handlers implemented for each route.

At this point we have implemented the procedure, taking into account its forms and handling them appropriately.

References

  1. Structure and Interpretation of Computer Programs
  2. Essentials of Programming Languages
Fork me on GitHub