Content deleted Content added
m →Structural equivalent: removed the section break, which made absolutely no sense |
→Introduction: merged two paragraphs after eliminating the senseless section-break. |
||
Line 7:
Jackson Structured Programming was similar to [[Warnier/Orr Diagrams|Warnier/Orr structured programming]]<ref>{{Citation | first = JD | last = Warnier | year = 1974 | title = Logical Construction of Programs | publisher = Van Nostrand Reinhold | place = NY}}</ref><ref>{{Citation | first = KT | last = Orr | year = 1980 | contribution = Structured programming in the 1980s | title = Proceedings of the ACM 1980 Annual Conference | publisher = ACM Press | place = New York, NY | pages = 323–26 | doi = 10.1145/800176.809987 | isbn = 978-0897910286 }}</ref> although JSP considered both input and output data structures while the Warnier/Orr method focused almost exclusively on the structure of the output stream.
At the time that JSP was developed, programs typically treated an input file as a sequence of records, so that all programs had the same structure— a single main loop that processed all of the records in the file, one at a time. Jackson asserted that this program structure was almost always wrong, and encouraged programmers to look for more complex data structures. In Chapter 3 of ''Principles of Program Design''<ref name="PoPD"/> Jackson presents two versions of a program, one designed using JSP, the other using the traditional single-loop structure. Here is his example, translated from COBOL into Java. The purpose of these two programs is to recognize groups of repeated records (lines) in a sorted file, and to produce an output file listing each record and the number of times that it occurs in the file.
Here is the traditional, single-loop version of the program.
<syntaxhighlight lang="java">
Line 31:
</syntaxhighlight>
Here is a JSP-style version of the same program. Note that (unlike the traditional program) it has two loops, one nested inside the other. The outer loop processes groups of repeating records, while the inner loop processes the individual records in a group.
<syntaxhighlight lang="java">
String line;
|