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 readers 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)
“I started off rapping for people just like myself, people who were in awe of wealth and flash. It was a conversation between me and them. But now most of those who buy my records are listening in on others conversation. They are the aural equivalent of voyeurs, thrilled at this crazy world that has nothing to do with their experience.”
—Ice-T [Tracy Marrow], U.S. rap musician. Observer (London, Oct. 27, 1991)