Nepedia
Back to Discover
Advanced Reader
💻

Structured programming

technology Maturity 11-13 Next article →

Structured programming is a specific way of organizing computer code. It uses a block-based structure to control the flow of instructions. This means the programmer decides the exact order in which the computer performs tasks. The main goal was to replace a command called "goto" with more organized tools. Without these tools, code often becomes a tangled mess known as "spaghetti code." This mess makes it very difficult for people to read or fix programs. Today, structured programming is so common that it is the standard way most software is written.

Structured program patterns
Structured program patterns

The core of this method relies on three specific control structures. The first is called a sequence. In a sequence, the computer executes statements in a strict, top-to-bottom order. The second is selection, which allows the program to choose between different paths. This is often done using "if-then-else" or "switch" statements based on a specific condition. The third is iteration, which is also called repetition. This allows a block of code to run repeatedly until a certain state is reached. Common keywords for this include "for" and "while."

Structured program patterns
Structured program patterns

These three structures are not just convenient; they are mathematically sufficient. The structured program theorem provides the theoretical foundation for this method. It states that sequencing, selection, and iteration can express any computable function. This means any task a computer can perform can be written using only these three patterns. While this idea relates to how central processing units work, the theorem is often credited to a 1966 paper by Böhm and Jacopini. This mathematical proof proved that the complex jumps of older methods were not strictly necessary.

Structured program patterns
Structured program patterns

The movement grew quickly during the late 1950s and 1960s. It emerged alongside the appearance of the ALGOL 58 and ALGOL 60 programming languages. ALGOL 60 was particularly important because it included support for block structures. A major turning point occurred in 1968 when Dutch computer scientist Edsger W. Dijkstra wrote an influential letter. His letter was titled "Go To Statement Considered Harmful." Dijkstra is actually the person who coined the term "structured programming." His work helped move the industry away from non-structured programming styles.

Structured program patterns
Structured program patterns

Many brilliant minds contributed to the development of these ideas during the 1960s and 1970s. Scientists such as Robert W. Floyd, Tony Hoare, Ole-Johan Dahl, and David Gries all made major contributions. There was also significant debate among experts. For example, Donald Knuth agreed that programs should be easy to prove as correct. However, he disagreed with completely banning the "goto" statement. In 1974, Knuth argued that direct jumps could sometimes make code more efficient and clear. He even proposed a specific rule for using jumps without creating a mess.

Structured program patterns
Structured program patterns

In the 1970s, the movement gained a powerful ally in IBM researcher Harlan Mills. He applied structured programming theory to build an indexing system for The New York Times research file. This project was a massive engineering success. Because of this success, many other companies began adopting these structured methods. Despite this, some people continued to argue against the strict rules. As late as 1987, Frank Rubin wrote a letter questioning the famous "Go To Statement Considered Harmful" idea. This shows that the transition to structured programming was a deep and ongoing discussion.

Structured program patterns
Structured program patterns

While the core rules are strict, many modern languages allow for some deviations. For instance, most languages allow for an "early return" or an "early exit." This means a program can leave a block of code before it reaches the very end. While the original theorem suggests there should be only one exit point, many developers find multiple exits more clear. Some experts, like Kent Beck and Martin Fowler, argue that clarity is more important than following strict rules. They suggest that using "guard clauses" can sometimes make code easier to understand than deeply nested structures. This balance between strict theory and practical clarity defines how we write software today.

652 words

Where will your curiosity go next?

Keep exploring at your chosen reading level.

🖼️ Images & Media (1)
File:Structured_program_patterns.svg
Structured_program_patterns.svg
More to explore

What is Nepedia?

A free, ad-free encyclopedia for children. Every article is written at five reading levels, so the same page works for a five-year-old and a fifteen-year-old — use the level switcher above to see this one change. No account needed to read.