encyclopegia.org

Jackson structured programming

Jackson structured programming (JSP) is a method for structured programming developed by British software consultant Michael A. Jackson. It was described in his 1975 book Principles of Program Design. The technique of JSP is to analyze the data structures of the files that a program must read as input and produce as output, and then produce a program design based on those data structures, so that the program control structure handles those data structures in a natural and intuitive way. JSP describes structures (of both data and programs) using three basic structures – sequence, iteration, and selection (or alternatives). These structures are diagrammed as (in effect) a visual representation of a regular expression.

Jackson structured programming (JSP) is a method for structured programming developed by British software consultant Michael A. Jackson. It was described in his 1975 book Principles of Program Design. The technique of JSP is to analyze the data structures of the files that a program must read as input and produce as output, and then produce a program design based on those data structures, so that the program control structure handles those data structures in a natural and intuitive way. JSP describes structures (of both data and programs) using three basic structures – sequence, iteration, and selection (or alternatives). These structures are diagrammed as (in effect) a visual representation of a regular expression. String line = null; int count = 0; String firstLineOfGroup = null; // begin single main loop while ((line = in.readLine()) != null) { if (firstLineOfGroup == null || !line.equals(firstLineOfGroup)) { if (firstLineOfGroup != null) { System.out.printf("%s %d%n", firstLineOfGroup, count); } count = 0; firstLineOfGroup = line; } count++; } if (firstLineOfGroup != null) { System.out.printf("%s %d%n", firstLineOfGroup, count); } 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. int numberOfLinesInGroup = 0; String line = in.readLine(); // begin outer loop: process 1 group while (line != null) { numberOfLinesInGroup = 0; String firstLineOfGroup = line; // begin inner loop: process 1 record in the group while (line != null && line.equals(firstLineOfGroup)) { numberOfLinesInGroup++; line = in.readLine(); } System.out.printf("%s %d%n", firstLineOfGroup, numberOfLinesInGroup); } Jackson criticises the traditional single-loop version for failing to process the structure of the input file (a sequence of groups containing repeating records) in a natural way. One sign of its unnatural design is that, in order to work properly, it is forced to include special code for handling the first and last record of the file. ==A worked example== As an example, here is how a JSP programmer would design and code a run length encoder. A run length encoder is a program whose input is a stream of bytes which can be viewed as occurring in runs, where a run consists of one or more occurrences of bytes of the same value. The output of the program is a stream of byte pairs, where each byte pair is a compressed description of a run. In each pair, the first byte is the value of the repeated byte in a run and the second byte is a number indicating the number of times that that value was repeated in the run. For example, a run of eight occurrences of the letter "A" in the input stream ("AAAAAAAA") would produce "A8" as a byte pair in the output stream. Run length encoders are often used for crudely compressing bitmaps. With JSP, the first step is to describe the data structure(s) of a program's input stream(s). The program has only one input stream, consisting of zero or more runs of the same byte value. Here is the JSP data structure diagram for the input stream. The second step is to describe the output data structure, which in this case consists of zero or more iterations of byte pairs. The next step is to describe the correspondences between the components of the input and output structures. The next step is to use the correspondences between the two data structures to create a program structure that is capable of processing the input data structure and producing the output data structure. (Sometimes this isn't possible. See the discussion of structure clashes, below.) Once the program structure is finished, the programmer creates a list of the computational operations that the program must perform, and the program structure diagram is fleshed out by hanging those operations off of the appropriate structural components. read a byte remember byte set counter to zero increment counter output remembered byte output counter Also, at this stage conditions on iterations (loops) and selections (if-then-else or case statements) are listed and added to the program structure diagram. while there are more bytes while there are more bytes and this byte is the same as the run's first byte and the count will still fit in a byte Once the diagram is finished, it can be translated into whatever programming language is being used. Here is a translation into C. include include int main(int argc, char* argv[]) { char first_byte; int count = 0; char c = getchar(); // get first byte while (c != EOF) { // process the first byte in the run first_byte = c; count = 1; c = getchar(); // get next byte // process the succeeding bytes in the run while (c != EOF && c == first_byte && count

References

No reference rows published for this article.

Cite this article

MLA

"Jackson structured programming." encyclopegia.org, 2026, https://encyclopegia.org/wiki/jackson-structured-programming. Accessed 24 November 2026.

Chicago

"Jackson structured programming." encyclopegia.org. Accessed November 24, 2026. https://encyclopegia.org/wiki/jackson-structured-programming.

APA

encyclopegia.org. (2026). Jackson structured programming. Retrieved November 24, 2026, from https://encyclopegia.org/wiki/jackson-structured-programming

Accessed November 24, 2026 · CC BY-SA 4.0 · citation page · JSON

Related articles

Philip V of Spain

enwiki · references available

The Spectator

enwiki · references available

Jesse Ventura

enwiki · references available

Brown v. Board of Education

enwiki · references available

Secrecy

enwiki · references available

Gudrun Ensslin

enwiki · references available
CC BY-SA 4.0 · share-alike · https://en.wikipedia.org/w/index.php?oldid=1361939756 · 0.5 · snapshot enwiki-001361939756

Cite · JSON · Search

Related services and records

Services

  • Estate — measured countries, lanes and facts
  • Intel — live corroborated events
  • Legal — statutes, cases and citations
  • Encyclopedia — articles with inline sources
  • Space — launches, satellites and orbits
  • Search — federated search and reports
  • Pass — passport account and SSO
  • Corpora — read-only corpus origins
  • e01 — self-hosted corpora and tools

Text and metadata only; each target carries its own sources. Missing data is published as no-data, never estimated.