Jackson structured programming: Difference between revisions

Content deleted Content added
Introduction: merged two paragraphs after eliminating the senseless section-break.
Introduction: added a little background about the state of the art of computing when JSP was developed
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, most programs typicallywere batch COBOL programs that processed sequential files stored on tape. A typical program read treatedthrough anits input file as a sequence of records, so that all programs had the same structure&mdash; 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.
Line 16:
String firstLineOfGroup = null;
 
// begin single main loop
while ((line = in.readLine()) != null) {
if (firstLineOfGroup == null || !line.equals(firstLineOfGroup)) {