Basic Principles of Structured Programming

Basic Principles of Structured Programming
Page content

A Quick Overview

Programming involves the creation of a series of lines, called code, which a computer executes. The lines comprise a program. Before structured programs came to the forefront, programmers were frequently guilty of writing “spaghetti code” programs. This was due to using the “Go To” statement in programs. With the “Go To” statement, the program code would be redirected to other areas of the program. Both the Basic and Fortran programming languages had no internal structure or limitations; free form was the rule.

Principles of structured programming help define a “high level” programming language; these are human readable language codes.

The alternative are low level languages, like Assembler, which are “close” to the hardware level and are full of cryptic symbolic code.

Enter structured programming with its goal to pursue a preferred programming task to make programs produce correct results, with as little redundancy as possible. A structured programming language program is written as a series of explicit statements. It generally does not contain the “Go To” command.

Writing structured programming can be less time consuming. If there is no need to write complex classes or functions, time will not be spent in developing them. Writing classes can take up more time and energy than just writing a piece of code, which executes a specific set of commands. However, as always, this depends on the overall purpose of the program. With structured programming, the separate pieces fall into place, so long as the pieces are well defined.

Source: Structured Programming with Go To Statements

Principles of Structured Programming

The base composition of any type of structured programming includes three fundamental elements. The first is sequencing, which has to do with the logical sequence provided by the statements in the program. As they are executed, each step in the sequence must logically progress to the next without producing any undesirable effects.

The second element is selection. This step allows the selection of any number of statements to execute in the program. These statements will contain certain keywords that can identify the sequence as a logically ordered executable. These terms are “if,” “then,” “endif,” or “switch.”

Structured Network

A third element is repetition. As a program proceeds, a select statement continues to be active until the program gets to the point where some other action needs to take place. The keywords include “repeat,” “for,” or “do…until.” The repetition factor dictates instructions to the program about how long to continue the operation before requesting further instructions.

Depending on the purpose and function of the program, the exact nature of structured programming will vary. For example, most forms of structured programming will have a single entry point but may have more than one exit point. In another form, called modular programming, the creation of modules within the overall structure of the program will interact with one another, depending on the type of code that is executed.

Source: Structured Programming


Comparison to Object Oriented Programming

While structured programming is still practiced, the majority of programs now use object oriented programming. In OOP the focus is not on the code but on what you want the code to do. So it is important to see how that practice developed. In OOP you have the following basic concepts: object, class, inheritance, methods, and polymorphism.

If you go back to the 1960s, SIMULA I (1962-65) and Simula 67 (1967) were the first two object-oriented languages. Simula 67 introduced most of the key concepts of object-oriented programming: both objects and classes. Programmers at Xerox PARC first coined the term ‘object-oriented programming.’ It designated a computer program that describes a methodology where the foundations for computation are objects.

Structured Network

OOP began its rise to prominence in the 1980s as the programming language of choice, with the success of C and C++. Now, OOP is common in programs such as Java, J2EE, C#, Visual Basic .NET, Python, and JavaScript. For a discussion, see an Introduction to the Microsoft .Net Framework. For a discussion of Java see Introduction to Java Programming.

Here are examples of code from both styles:

Structured Programming:

---Program starts




function1 { … }

function2 { … }

function3 { … }

main { … }

-– Program Ends

Explanation: You have code that operates on variables and the code is called as a reference to those variables. They follow a structure by acting on those variables.

Object Oriented Programming:

-– Program Starts-





functionA { … }

functionB { … }

functionC { … }




functionD { … }

main { … }

-– Program ends

Variables can be objects, not just placeholders; they have their own data and functions. So instead of creating data units to pass to functions that will operate on them, you will create objects that perform operations on themselves.

Here are some additional comparisons.

  • Structured Programming allows you to declare only the member; however, with OOP you can declare members and define methods.
  • Structured Programming allows you to view like data and functions as separate entities, whereas OOP lets you view data and functions as a single entity by using class feature.
  • Structured Programming only has attributes, but OOP has attributes and functionality.

Source: How Object-Oriented Programming Started

Picture: Neural Network Model


Structured programming began the theoretical study of programming design. It forced programmers to approach programming from the conceptual point of view, making them design programs before they wrote code. It cleared up spaghetti code and forced the concept of correctness into the program.