As the term implies, pseudocode is a "quasi" programming language, an attempt to combine the informality of natural language with the strict syntax and control structures of a programming language. In the extreme form, pseudocode consists of combinations of:
Figure 24-1 shows an example of a pseudocode specification of an algorithm for calculating deferred-service revenue earned within a given month in a business application. Note that the text of the pseudocode is indented, in an outline-style format, in order to show "blocks" of logic. The combination of the syntax restrictions and the format and layout of the text greatly reduces the ambiguity of what could otherwise be a very difficult and error-prone requirement. (It certainly was before we wrote the pseudocode.) At the same time, it should be possible for a nonprogramming person (for example, Rhonda the bookkeeper) to read and understand the requirement in the form shown in Figure 24-1. Figure 24-1 Example of pseudocodeThe algorithm for calculating deferred-service revenue earned for any month is: Set SUM(x)=0 FOR each customer X IF customer purchased paid support AND ((Current month) >= (2 months after ship date)) AND ((Current month) <= (14 months after ship date)) THEN Sum(X)=Sum(X) + (amount customer paid)/12 END |