<- People Behind Informatics


All 0-9 A B C D E F G H I J K L M N O P Q R S T U V W XY Z




 
Structured Programming
Structured programming (SP) may be defined as a methodological style whereby a computer program is constructed by concatenating or coherently nesting logical subunits that either are themselves structured programs or else are of the form of one or another of a small number of particularly well-understood control structures. Such a definition is inherently and deliberately recursive. Though the idea is of uncertain and undoubtedly multiple parentage, intense interest in the concept followed the publication of a letter to the editor in Communications of the ACM in March 1968 by Edsger Dijkstra. In this letter, entitled by Niklaus Wirth, the editor of CACM "Go To Statement Considered Harmful," Dijkstra reported his observation that the ease of reading and understanding program listings was inversely proportional to the number of unconditional transfers of control ("goto"s) that they contained. This rule of thumb is quite plausible since, when a programmer suddenly writes goto, what he or she is essentially saying to the reader is "However hard you were concentrating on the logical flow of my program, stop and find the continuation of this logic at another (possibly remote) physical point. " That new point is presumably marked by a label of some sort (numeric in Fortran or Pascal, or alphanumeric in Algol or APL, etc.), which may not even be on the same page that contained the goto. The front page of any daily newspaper is full of gotos (e.g. "cont'd on p. 6") for the obvious reason that the editors want to draw attention to a large number of unrelated stories of approximately co-equal importance. At least some magazines are more considerate, however, and always finish one thought (article) before beginning another. Why can't programmers? Their ability to do so is at the heart of structured programming. As an example, let’s take an algorithm that adds the first N (N >0) integers. In an old-fashioned programming language without structured constructs the code would contain labels and goto statements jumping to these: 1: sum:= 0; x:= 1; 2: if x <= N then goto 3; goto 4; 3: sum:= sum + x; x:= x + 1; goto 2; 4: Note how error prone this code is. If for example the third goto statement jumps erroneously to label 1 instead of 2, then the program never terminates (except if N =0). Still worse, it could happen that a jump is made form elsewhere to label 2 or 3, leading to fully hazardous results. Using symbolic labels is only a superficial treatment and does not cure the essence of the problem. In an Algol-like language the well-structured while statement (repeating the statements between while and end as long as the condition between while and do is true) eliminates a large part of the above weaknesses. The programmer is of course still responsible both for correctness and for proper termination of the code. However, he can demonstrate these properties much more easily with an Algol-like coding than with the coding shown above. sum:= 0; x:= 1; while x <= N do sum:= sum + x; x:= x + 1; end; Structured Programming Go To Statement [Source: Encyclopedia of Computer Science, Fourth Edition, Anthony Ralston, Edwin D. Reilly, David Hemmendinger; Laszlo Böszörmenyi: Notes to the Virtual Exhibition "People behind Informatics"]
 

 

<- People Behind Informatics


Home  |  Top  |  Search  |  Gallery  | Glossary  | Sitemap  |  Making Of  |  Help