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

Structured programming

Structured programming is a programming paradigm characterized by source code that uses block-based source code structure to encode control flow such as sequence, selection (i.e. if-then-else and switch) and iteration (i.e. for and while).

Originally, the central goal of the structured programming movement was to eliminate the need for and use of the goto statement. As goto provides powerful and flexible flow control, it can be used to write any arbitrarily complex algorithm, but the resulting code often has significant quality issues, commonly described as spaghetti code. Structured programming replaces goto with constructs that tend to result in better code. The paradigm became popular and for the most part achieved the goal of supplanting goto. In fact, its ubiquity is so thorough that for much of software development, it is simply the way code is written, and is no longer a topic of discussion as it once was.

Structured programming is sometimes associated with modular programming even though they are different. In a general sense, structured implies a sense of modularity and of being written to be efficient and easy to understand and modify, but this is not what structured programming means in a narrow sense.

After structured programming became popular, the style of programming that preceded it was retroactively called non-structured programming. Although technically a programming paradigm, it differs from other paradigms in that it was not intentionally designed. It was simply the state-of-the-art before structured programming was envisioned.

else. The conditional statement should have at least one true-condition path, and each condition path should have just one exit point.
Iteration
(a.k.a. repetition) A block (which can be a single statement) is executed repeatedly until the program reaches a certain state. This construct is often expressed with keywords such as while, repeat, for, or do-until. Although structured programming limits the flow to have exactly one entry point and exactly one exit point, most languages allow for multiple, early exit.
Graphical representation of the three basic patterns—sequence, selection, and iteration—using NS diagrams (blue) and flow charts (green).

Language support

edit

Generally, a language is intended to support one or more programming paradigms. At the same time, even though a language is not intended to support a paradigm, it often can be used in that way regardless. In theory, any language can be used for structured programming. Some of the languages initially used for structured programming include ALGOL, Pascal, PL/I, Ada, and RPL, but most new procedural programming languages since that time have included features to encourage structured programming, and sometimes deliberately left out features


View original on Wikipedia | Back | FazBrowse Home