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)

    But then people don’t read literature in order to understand; they read it because they want to re-live the feelings and sensations which they found exciting in the past. Art can be a lot of things; but in actual practice, most of it is merely the mental equivalent of alcohol and cantharides.
    Aldous Huxley (1894–1963)