Jackson Structured Programming - Structural Equivalent

Structural Equivalent

The JSP version of the program is structurally equivalent to

String line; line = in.readLine; while (line != null) { int count = 0; String firstLineOfGroup = line; while (line != null && line.equals(firstLineOfGroup)) { count++; line = in.readLine; } System.out.println(firstLineOfGroup + " " + count); }

and the traditional version of the program is equivalent to

String line; int count = 0; String firstLineOfGroup = null; while ((line = in.readLine) != null) { if (firstLineOfGroup == null || !line.equals(firstLineOfGroup)) { if (firstLineOfGroup != null) { System.out.println(firstLineOfGroup + " " + count); } count = 0; firstLineOfGroup = line; } count++; } if (firstLineOfGroup != null) { System.out.println(firstLineOfGroup + " " + count); }

Jackson criticises the traditional version, claiming that it hides the relationships which exist between the input lines, compromising the program's understandability and maintainability by, for example, forcing the use of a special case for the first line and forcing another special case for a final output operation.

Read more about this topic:  Jackson Structured Programming

Famous quotes containing the words structural and/or equivalent:

    The reader uses his eyes as well as or instead of his ears and is in every way encouraged to take a more abstract view of the language he sees. The written or printed sentence lends itself to structural analysis as the spoken does not because the reader’s eye can play back and forth over the words, giving him time to divide the sentence into visually appreciated parts and to reflect on the grammatical function.
    J. David Bolter (b. 1951)

    Every notable advance in technique or organization has to be paid for, and in most cases the debit is more or less equivalent to the credit. Except of course when it’s more than equivalent, as it has been with universal education, for example, or wireless, or these damned aeroplanes. In which case, of course, your progress is a step backwards and downwards.
    Aldous Huxley (1894–1963)