My Account

Three Basic Structures Of Structured Programming

Length: 1073 words (3.1 double-spaced pages)
Rating: Excellent
Open Document
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Text Preview

Structured programming is one of the several different ways in which a programming language can be constructed. "It was originally introduced as a means of getting away from the 'spaghetti' code that was used in the early days and to provide some means by which programmers could more easily follow code written by other programmers." (Hendren, 1998) Structured programming is a procedure-oriented method of designing and coding a program.
At a low level, structured programs are composed of simple, hierarchical program flow structures. "These are regarded as single statements, and are the same time ways of combining simpler statements, which may be one of these structures, or primitive statements such as assignments or procedure calls." (Dijkstra, 1990) The three basic types of structure identified by Dijkstra were concatenation, selection, and repetition.

Simple sequential code is most easily expressed by concatenation i.e. listing the pieces of code in the correct order. The main related question is how to indicate the boundary between statements. "Some languages just use the end of line but then usually require an explicit continuation symbol for statements too long to fit on a single line. Others languages use an explicit character such as, with some of these treating it as a separator and the rest treating it as the statement terminator." (Birrell, 1995)
To turn a code sequence into a single entity, usually known as a compound statement, some languages use an explicit pair of brackets, such as {} or begin end, as a general form useable with any structure. Some languages have specific forms for each structure, such as if fi (or if end if) and while od (or while end while). Some languages have both general and specific forms, and others have neither. Because structures often end up deeply nested, specific keywords can be much easier to pair up than general pairs.
"The classic selector is the conditional or if statement/expression, and almost all languages have it, usually in two slightly different forms such as if then and if then else." (Agresti, 2000) Some languages place restrictions on the then and else parts, but most modern languages have no such restrictions, allowing nested if statements.
One common pattern of use is:
If ... then...
Else if ... then...
Else if ... then...
. . .
else ...
And this has given rise to a different kind of selection construct, the case or switch. This first arose as a modified goto:
goto label_array[n]
But this was even more dangerous than normal gotos, and was also replaced. A switch construct is essentially a list of (value, action) pairs. We can generalize the switch into a block of guarded statements, where at most one of the statements is obeyed e.g.:
I < j then j -= I
j < I then I -= j
We can even allow for more than one of the guard expressions being valid, either by picking the first such in the list, or by non-deterministically picking a valid guard at random.
"Repetition comes in two forms: recursion and loops. Some languages have both; some only have one or the other. Loops come in two forms: indeterminate, where the number of repetitions is unknown until the loop terminates, and determinate, where the number of repetitions is known when the loop starts. Again, some languages with iteration have both forms, some only one and the other." (Jackson, 2002)
Dijkstra's (indeterminate) repetition construct, which involves a test in the middle of the loop, is not often directly implemented in programming languages. However, special cases of it are common: a version with the first box missing so the test is at the start is found in most languages, and a version with the last box missing so the test is at the end is often found as well.
"Almost all languages provide some sort of determinate loop, usually known as a for-loop or do-loop. The basic form is a loop that e.g. counts from 1 to 10, and some languages provide little more than this: e.g.: for I = 1 to 10 do." (Fream, 1992)
Because of this some languages do not bother to test the condition until the end of each repetition. Various enhancements exist: variables or expressions for start and stop values, increments other than 1, decrements, automatic declaration of the counter variable, scalar types other than integer.
Some languages guarantee a particular value of the counter outside the loop or permit it to be modified inside the loop, whereas others do not, so as to allow for optimizations and because modifying the counter does not lead to good quality code.
We can transform the while statement into a loop containing a list of guarded statements, that repeats until none of the guards is valid e.g.:
I < j do j -= I
J < I do I -= j
This example terminates when I equals j.

Coders should break larger pieces of code into shorter subroutines (functions, procedures. methods, blocks, or otherwise) that are small enough to be understood easily. In general, programs should use global variables sparingly; instead, subroutines should use local variables and take arguments by either value or reference. These techniques help to make isolated small pieces of code easier to understand without having to understand the whole program at once.

Erosa, Hendren: (1998) Structured Programming, Language Design, and Persistence.

E.W. Dijkstra: (1990) Structured Programming: Three Basic Structures of Structured Programming, Academic Press, London.

Andrew D. Birrell: (1995) Programming with Threads, Research Report 35, Systems Research Center, Digital Equipment Corporation.

William Agresti: (2000) Three Basic Structures of Structured Programming, Journal of Programming.

M.A. Jackson: (2002) Basic controls and structures of Structured Programming, Journal of software development.

Skinner Fream: (1992) Structured Programming, program flow structures, Yale University press

How to Cite this Page

MLA Citation:
"Three Basic Structures Of Structured Programming." 04 Dec 2016

Related Searches

Important Note: If you'd like to save a copy of the paper on your computer, you can COPY and PASTE it into your word processor. Please, follow these steps to do that in Windows:

1. Select the text of the paper with the mouse and press Ctrl+C.
2. Open your word processor and press Ctrl+V.

Company's Liability (the "Web Site") is produced by the "Company". The contents of this Web Site, such as text, graphics, images, audio, video and all other material ("Material"), are protected by copyright under both United States and foreign laws. The Company makes no representations about the accuracy, reliability, completeness, or timeliness of the Material or about the results to be obtained from using the Material. You expressly agree that any use of the Material is entirely at your own risk. Most of the Material on the Web Site is provided and maintained by third parties. This third party Material may not be screened by the Company prior to its inclusion on the Web Site. You expressly agree that the Company is not liable or responsible for any defamatory, offensive, or illegal conduct of other subscribers or third parties.

The Materials are provided on an as-is basis without warranty express or implied. The Company and its suppliers and affiliates disclaim all warranties, including the warranty of non-infringement of proprietary or third party rights, and the warranty of fitness for a particular purpose. The Company and its suppliers make no warranties as to the accuracy, reliability, completeness, or timeliness of the material, services, text, graphics and links.

For a complete statement of the Terms of Service, please see our website. By obtaining these materials you agree to abide by the terms herein, by our Terms of Service as posted on the website and any and all alterations, revisions and amendments thereto.

Return to