FazBrowse Wikipedia Viewer | Main Page |
Search Wikipedia:
|
Viewing: https://en.wikipedia.org/wiki/Jackson_structured_programming

Jackson structured programming

Contents
The basic method
Techniques for handling difficult design problems
JSP and object-oriented design
See also
References
External links

Example of a JSP diagram.

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.

intnumberOfLinesInGroup=0; Stringline=in.readLine(); // begin outer loop: process 1 group while(line!=null){ numberOfLinesInGroup=0; StringfirstLineOfGroup=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.

The basic method

edit

JSP uses semi-formal steps to capture the existing structure of a program's inputs and outputs in the structure of the program itself.

The intent is to create programs which are easy to modify over their lifetime. Jackson's major insight was that requirement changes are usually minor tweaks to the existing structures. For a program constructed using JSP, the inputs, the outputs, and the internal structures of the program all match, so small changes to the inputs and outputs should translate into small changes to the program.

JSP structures programs in terms of four component types:

The method begins by describing a program's inputs in terms of the four fundamental component types. It then goes on to describe the program's outputs in the same way. Each input and output is modelled as a separate Data Structure Diagram (DSD). To make JSP work for compute-intensive applications, such as digital signal processing (DSP) it is also necessary to draw algorithm structure diagrams, which focus on internal data structures rather than input and output ones.

The input and output structures are then unified or merged into a final program structure, known as a Program Structure Diagram (PSD). This step may involve the addition of a small amount of high-level control structure to marry up the inputs and outputs. Some programs process all the input before doing any output, whilst others read in one record, write one record and iterate. Such approaches have to be captured in the PSD.

The PSD, which is language neutral, is then implemented in a programming language. JSP is geared towards programming at the level of control structures, so the implemented designs use just primitive operations, sequences, iterations and selections. JSP is not used to structure programs at the level of classes and objects, although it can helpfully structure control flow within a class's methods.

JSP uses a diagramming notation to describe the structure of inputs, outputs and programs, with diagram elements for each of the fundamental component types.

A simple operation is drawn as a box.

An operation"}},"i":0}}]}'>

The next step is to describe the correspondences between the components of the input and output structures.

\n\nint main(int argc, char* argv[]) {\n char first_byte;\n int count = 0;\n\n char c = getchar(); // get first byte\n while (c != EOF) {\n // process the first byte in the run\n first_byte = c;\n count = 1;\n c = getchar(); // get next byte\n\n // process the succeeding bytes in the run\n while (c != EOF && c == first_byte && count < 255) {\n // process one byte of the same value\n count++;\n c = getchar(); // get next byte\n }\n\n putchar(first_byte);\n putchar(count);\n }\n return EXIT_SUCCESS;\n}\n"}}'>#include<stdio.h> #include<stdlib.h> intmain(intargc,char*argv[]){ charfirst_byte; intcount=0; charc=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<255){ // process one byte of the same value count++; c=getchar();// get next byte } putchar(first_byte); putchar(count); } returnEXIT_SUCCESS; }

Techniques for handling difficult design problems

edit

In Principles of Program Design Jackson recognized situations that posed specific kinds of design problems, and provided techniques for handling them.

One of these situations is a case in which a program processes two input files, rather than one. In 1975, one of the standard "wicked problems" was how to design a transaction-processing program. In such a program, a sequential file of update records is run against a sequential master file, producing an updated master file as output. (For example, at night a bank would run a batch program that would update the balances in its customers' accounts based on records of the deposits and withdrawals that they had made that day.) Principles of Program Design provided a standard solution for that problem, along with an explanation of the logic behind the design.

Another kind of problem involved what Jackson called "recognition difficulties" and today we would call parsing problems. The basic JSP design technique was supplemented by POSIT and QUIT operations to allow the design of what we would now call a backtracking parser.

JSP also recognized three situations that are called "structure clashes"— a boundary clash, an ordering clash, and an interleaving clash— and provided techniques for dealing with them. In structure clash situations the input and output data structures are so incompatible that it is not possible to produce the output file from the input file. It is necessary, in effect, to write two programs— the first processes the input stream, breaks it down into smaller chunks, and writes those chunks to an intermediate file. The second program reads the intermediate file and produces the desired output.

JSP and object-oriented design

edit

JSP was developed long before object-oriented technologies became available. It and its successor method JSD do not treat what now would be called "objects" as collections of more or less independent methods. Instead, following the work of C. A. R. Hoare, JSP and JSD describe software objects as co-routines.

See also

edit

References

edit
    Warnier, JD (1974), Logical Construction of Programs, NY: Van Nostrand Reinhold
  1. ↑ Henderson-Sellers, Brian; Edwards, JM (Sep 1990), "The object-oriented systems life cycle", Communications of the ACM, 33 (9): 142–59, doi:10.1145/83880.84529, S2CID 14680399.

External links

edit
Wikimedia Commons has media related to Jackson Structured Programming.
Programming paradigms
Imperative
Structured
Object-oriented
Declarative
Functional
Dataflow
Logic
Domain-
specific
language

(DSL)
Concurrent,
parallel
Metaprogramming
Separation
of concerns
Comparisons/Lists
Comparison (multi-paradigm, object-oriented, functional), List (OO, by type)

View original on Wikipedia | Back | FazBrowse Home