Structured programming

Structured programming is a programming paradigm in which a program’s control flow is expressed exclusively through three fundamental constructs: sequence (statements executed in order), selection (conditional branching via if/else and switch), and iteration (loops via for, while, and similar).

These three constructs were shown by Böhm and Jacopini in 1966 to be sufficient to express any computable algorithm.

The movement was galvanized by Edsger Dijkstra’s influential 1968 letter Go To Statement Considered Harmful, which argued that the goto statement — while powerful enough to encode any control flow — actively degrades the quality of code by making it difficult to reason about program state at any given point. Code written with liberal use of goto was characterized by tangled, difficult-to-follow paths that became known as [spaghetti code].

Structured programming replaces these arbitrary jumps with well-defined, composable constructs whose behavior is predictable and whose scope is clear.

The paradigm was championed by Dijkstra, Niklaus Wirth, and Tony Hoare, among others, and became the dominant approach to imperative programming through the 1970s and 1980s. Its success was so complete that it effectively ceased to be a topic of debate: structured control flow is now simply the default expectation of all mainstream programming languages. Most modern languages either omit goto entirely or strongly discourage its use.

Fred Brooks endorsed the approach, noting that restricting control structures to a specified, well-understood set is a sound way to avoid bugs and the right way to reason about programs.

Structured programming also laid the groundwork for [stepwise refinement] and later paradigms. [Object-oriented programming], for example, built on its procedural foundations while adding mechanisms for organizing data alongside behavior.