[Home]Structured programming

HomePage | Recent Changes | Preferences

Showing revision 7
Structured programming can be seen as a subset or subdiscipline of Procedural programming, one of the major paradigms (and probably the most popular one) for programming computers.

It is possible to do structured programming in almost any procedural programming language, but since about 1970 when structured programming began to gain popularity as a methodology, most new procedural programming languages have included features to encourage structured programming, (and sometimes have left out features that would make unstructured programming easy). Some of the better known structured programming languages are

At the level of relatively small pieces of code, structured programming typically recommends simple, hierarchical program flow structures. These can be obtained in most modern languages by using only structured looping constructs, often named "while", "repeat", "for". Often it is recommended that each loop should only have one entry point and one exit point, and a few languages enforce this.

Alternative thinking on structured loops exists. Donald Knuth has advocated flow graphs that can be written with all forward branches drawn to the left of the code, all backward branches drawn to the right, and no branches crossing each other in this representation. Those knowlegeable in compilers and graph theory have advocated allowing only reduceable flow graphs.

For larger pieces of code, the use of subroutines (functions and procedures in some languages) is encouraged, and it is recommended that each subroutine should be small enough to be understood easily. Use of variables local to the subroutine, and also use of parameters, is highly encouraged, while excessive use of global variables is frowned on. All this is to make it easier to understand small pieces of code in isolation, without having to understand the whole program at once.

Structured programming is often (but not always) associated with a "top-down" approach to both design and programming. In this way the large scale structure of a program is designed and implemented first, in terms of smaller operations that will be fully designed and implemented later.

By the end of the 20th century, structured programming was endorsed by the vast majority of serious programmers using the procedural programming paradigm. The main benefit claimed is that structured programs are supposed to be easier to understand, leading to improved reliability and easier maintenance. Attempts to actually measure this have been rare, and there is a suspicion in some circles that the benefits are real but small.

Towards the end of the 20th century, there have been serious attempts at paradigms that are loosely based on proceedural programming, and accept the lessons of structured programming, but attempt to go beyond this in providing structure for data as well as for program flow. Object-oriented programming in most cases can be seen as an example of this, although there are also some object-oriented variants that are not procedural.

Structured programming languages provide constructs for creating a variety of loops and conditional branches of execution. Unstructured languages provide a method of creating a label in code and a GOTO command.

Strictly speaking, in a structured programming language, any code structure should have only one entry point and one point of exit; but, in many programming languages, such as C, it is possible to create multiple exit points.

/Talk


HomePage | Recent Changes | Preferences
This page is read-only | View other revisions | View current revision
Edited October 11, 2001 4:28 pm by 203.37.81.xxx (diff)
Search: