Computer programs that perform complicated tasks tend to be very complex themselves. Over the years a number of different forms of programming have emerged with the common goal of simplifying the process of creating and maintaining large computer programs.
The most established such form is called structured programming
is a form of programming in which large, complex tasks are broken into smaller, simpler tasks. You can think of structured programming as a strategy for building a large computer program from a collection of little subprograms.
Depending on the programming language in use, these subprograms may be referred to as
- procedures, or
Structured programming is a subset of procedural programming and is also known as modular programming. A structured programming language consists of a logical programming method that is considered a precursor to object-oriented programming (OOP). Its main purpose to enforce a logical structure on the program being written to make it more efficient and easier to understand and modify.
The structured programming language allows a programmer to code a program by dividing the whole program into smaller units or modules. Structured programming is not suitable for the development of large systems and does not allow re-usability of written code the way an object oriented language does. It is a programming paradigm aimed at improving the quality, clarity, and access time of a computer program by the use of subroutines, block structures, for and while loops.
In addition, structured programming enforces a logical structure on the program being written to make it more efficient and easier to understand and modify. Certain languages such as Ada, Pascal, and Algol are designed with features that encourage or enforce a logical program structure.
Structured programming frequently employs a top-down design model, in which developers map out the overall program structure into separate subsections. A defined function or set of similar functions is coded in a separate module or submodule, which means that code can be loaded into memory more efficiently and that modules can be reused in other programs. After a module has been tested individually, it is then integrated with other modules into the overall program structure.
The program flow follows a hierarchical model that employs looping constructs such as "for," "repeat," and "while" and use of the "Go To" statement is discouraged.
Corrado Bohm and Guiseppe Jacopini were the two mathematicians who demonstrated that any computer program can be written with just three structures:
- sequences, and
Edsger Dijkstra's subsequent article, Go To Statement Considered Harmful
was instrumental in the trend towards structured programming. The most common methodology employed was developed by Dijkstra. In this model the developer separates programs into subsections that each have only one point of access and one point of exit.
Almost any language can use structured programming techniques to avoid common pitfalls of unstructured languages. Unstructured programming must rely upon the discipline of the developer to avoid structural problems, and as a consequence may result in poorly organized programs. Most modern procedural languages include features that encourage structured programming.
Object-oriented programming (OOP) can be thought of as a type of structured programming, uses structured programming techniques for program flow, and adds more structure for data to the model.
Within the subprograms that make up a structured program
the following control flow constructs are used:
Structured programming: A form of programming in which large, complex tasks are broken into smaller, simpler tasks.
These constructs allow you to produce well-organized programs in which the program logic is easy for you and other programmers to understand.
We will be looking at these control flow constructs in some detail in the lessons ahead, but first, to help you appreciate the benefits of structured
programming, it is instructive to consider a program that is not structured. In the next lesson we will do exactly that.