Structured Programming  «Prev  Next»
Lesson 2 Simplifying programs
Objective Describe Structured Programming.

Describe Structured Programming

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. 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
  1. modules,
  2. subroutines, (for example in Fortran 77)
  3. functions, (in C and
  4. procedures, or
  5. methods.

What is Structured Programming?

Structured programming is a subset of procedural programming and is also known as modular programming[1]. 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:
  1. decisions,
  2. sequences, and
  3. loops.


Origins of Structured Programming

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.

Arguments for Structured Programming

The core arguments for structured programming did see some evolution between 1970 and 1990, reflecting advancements in technology and development practices. Here's a breakdown: Main arguments in the 1970s:
  • Reduced complexity: Countering spaghetti code, structured programming emphasized control flow structures (sequence, selection, iteration) for clearer, more modular code. This promoted better understanding, debugging, and maintenance.
  • Improved reliability: Structured code was less prone to errors due to predictable execution flow and reduced reliance on complex goto statements. This led to more reliable and stable software.
  • Enhanced team collaboration: The modularity and clarity of structured code facilitated communication and collaboration within development teams. It became easier to understand each other's code and work together effectively.

Evolution in the 1980s and 1990s:
  • Focus on data structures: As data-driven applications grew, data structures like stacks, queues, and trees gained importance. Structured programming adapted to incorporate these concepts, leading to more efficient and organized data handling.
  • Object-oriented programming (OOP): The emergence of OOP in the 1980s further refined structured programming principles. Encapsulation, inheritance, and polymorphism fostered code reusability, maintainability, and closer modeling of real-world problems.
  • Formal methods and verification: Growing software complexity led to a push for formal methods and verification techniques. Structured programming, with its well-defined control flow, provided a foundation for these more rigorous approaches to ensuring software correctness.

While the core arguments remained consistent, the emphasis shifted:
  • From avoiding errors to promoting efficient design and data management.
  • From individual programmer understanding to facilitating teamwork and collaboration.
  • From simple control flow to integrating with higher-level concepts like data structures and object-oriented principles.

Additional factors:
  • Advancements in programming languages: Newer languages with built-in support for structured constructs (e.g., Pascal, C) eased adoption and broadened its reach.
  • Development methodologies: Structured programming became the cornerstone of methodologies like waterfall and agile, impacting development processes.
  • Overall, the arguments for structured programming evolved to address new challenges and opportunities in software development, while retaining its core values of clarity, reliability, and maintainability.

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.
  1. Sequence
  2. Decision
  3. Repetition

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.

[1]Modular programming:Modular programming is a software design technique that emphasizes separating the functionality of a program into independent, interchangeable modules, such that each contains everything necessary to execute only one aspect of the desired functionality.

SEMrush Software