Pseudocode

   

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:

  • Imperative sentences with a single verb and a single object

  • A limited set, typically not more than 40 “50, of " action-oriented " verbs from which the sentences must be constructed

  • Decisions represented with a formal IF-ELSE-ENDIF structure

  • Iterative activities represented with DO-WHILE or FOR-NEXT structures

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 pseudocode

The 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 
   


Managing Software Requirements[c] A Use Case Approach
Managing Software Requirements[c] A Use Case Approach
ISBN: 032112247X
EAN: N/A
Year: 2003
Pages: 257

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net