The structured programming It is a provision in the design and construction of computer programs, with the aim of improving the management of its complexity, taking into account the peculiarities of human thought. Every program is based on an algorithm and can be represented by a logical scheme.
It arose from the increasing complexity of computerized programs. It has become a new programming scheme that created new techniques to be able to produce programs that are safe to operate for longer..
Thanks to the rapid development of computerized data processing, in the late 1960s it was possible to solve increasingly complex problems. However, understanding, debugging, and modifying these programs presented difficulties that made them unreliable..
The large computer programs made for these problems had source codes so long and unstructured that they had become quite complicated to access and navigate with some logic, even for their own authors..
Article index
Programmers used the “goto” command in programming languages to perform a conditional branching, which often led to readability and not to preserve a logical context.
In this software crisis, the question arose as to whether a general and disciplined methodology could be systematically developed that would allow for more refined programs. As a response to this approach, the structured programming method was born.
In 1968, Dijkstra published the article "Goto, the command considered harmful", where he pointed out that the indiscriminate use of this command had a negative effect on the readability and understanding of computer programs..
Niklaus Wirth designed a new programming language, called Pascal, released in 1970. Since then it has been used extensively to teach the design of structured programming..
This programming mode is characterized by the fact that programmers can fragment the source code of their programs into logically structured blocks, which consist of loops, logic blocks and conditional commands..
The goal of structured programming is to make programs that are easy to write, debug, and modify. The programs achieved are clear, ordered, understandable, without jumps.
Dijkstra devised a theory linked to structured programming, which indicated that when designing any program it is convenient to take into account the following fundamentals:
- The structural theorem, which states that any program can be compiled using only three essential control structures: sequential structure, alternative structure, and repetitive structure.
- When outlining the programs, it is exhorted to apply the descending technique, also called top-down..
- Validity and visibility ranges of variables and data structures must be limited.
The structural theorem indicates that any algorithm with a single starting and ending point can be constituted as a composition of three control structures..
By logically and clearly programming these supported control structures, structured programming enables efficient approach to functions with any degree of difficulty.
This structure is simply the sequence or succession of two or more operations or commands.
It is the selection of a command between two possible alternatives. It is also allowed to choose between more than two alternatives.
Certain commands are repeated as long as a certain condition is met. Also the cycle can be performed with a counter.
Structured programming is based on well-defined functional modules, ranked according to the specific nature of the problem. This programming is an independent method of the programming language, acting more like a style of programming.
It is a way of devising programs following well-established rules, using a certain set of control structures..
Structured programming allows programs to be written in pseudocode, regardless of the language of the machine, close to natural, convertible into any programming language.
Almost any sample code snippet in any modern programming language will be an example of structured programming..
This programming uses loops, conditionals and subroutines to control the flow and modularity in order to facilitate the reading and to be able to reuse the code.
You can run a list of statements in order, from top to bottom. In this case, a natural language program for baking bread is given as an example:
- Add flour.
- Add yeast.
- Add salt.
- Mix.
- Add water.
- Knead.
- Let the dough rise.
- To bake.
A block of statements is repeated as long as a condition is true. For example: washing dishes.
At most one action is chosen from several alternative conditions. For example: sort mail.
Lines or blocks of code are written and executed in sequential order. For example, you have:
x = 6
y = 12
z = x + y
WriteLine (z)
A code block is repeated as long as a condition is met. There is no limit to the number of times the block can be executed. Example:
x = 2
While x<100
WriteLine (x)
x = x * x
End
A block of code is executed if a condition is true. The code block is executed at most once. Example:
x = ReadLine ()
If x Mod 2 = 0
WriteLine ("The number is even")
End of yes
- They are programs that meet the needs of customers.
- Although it takes longer to generate the code initially, it often results in code that runs without errors when it is first run.
- It is similar to the vocabulary of words and symbols in English.
- Easy to handle program changes with new specifications in the future.
- They are easier to maintain.
- It is easy to use and understand. Eventually less time is required to write the code. It is easier to learn.
- The program written in a high-level language can be translated into many machine languages. Therefore, it can be run on any computer for which there is a suitable translator or compiler..
- They are primarily problem oriented rather than machine oriented.
- It is independent of the computer on which it is used. That is, programs developed in high-level languages can be run on any computer.
Structured programming reduces the chance that one function will affect another. This makes programs to be written clearer, since global variables are removed to be replaced by local variables.
Due to this change, the memory allocation space that a global variable occupies can be saved.
The organization helps to easily understand the programming logic, in order to understand the logic behind the programs.
It also helps newcomers from any tech company understand programs created by other industry workers, thus facilitating potential code debugging..
- The translator or compiler has to translate the high-level language into machine language. Therefore, a price has to be paid in the use of computer time..
- Compiler generated object code can be inefficient when compared to an equivalent assembly language program.
The code that is written can appear in different parts of the program. It can be vulnerable to various problems due to its location. Programs have variables, which means that they can take different values in different parts of the program..
The type of the data comes from many functions. Therefore, when changes occur in that type of data, the corresponding change must be made in each location that acts on that type of data within the program. This is a really time consuming task if the program is very large.
The case of software development can be considered, where several programmers work as a team on an application. In a structured program, each programmer will be assigned to build a specific set of functions and data types.
Therefore, different programmers will separately handle different functions that have data types shared with each other..
The other programmers on the team must reflect the changes in the data types made by a programmer, in the data types they have handled. Otherwise, multiple functions will have to be rewritten.
Structured programming has worked well for millions of programs and billions of lines of code. There is no reason to throw it away.
In particular, it has worked extremely well for programs that process data and for number processing, both of which are run once to produce a response..
Two characteristics tend to define well the problems that can be approached in a purely structured way:
- The data to be handled closely matches the data types that are integrated into the language, generally being numbers and character strings..
- The program follows a well-defined flow of control to produce a single result based on some input.
Computer programs with these characteristics include many scientific, engineering, and word processing applications, as well as many of the textbook examples of traditional computer science courses..
Not surprisingly, these are exactly the kinds of programs that the first people who invented programming languages wanted to solve..
Most modern programming languages are structured in this way: what you have in the program are objects, and most of the code consists of different methods of using the data stored in those objects.
A structured program generally has control over what happens and when it happens, whereas an event-based program must be able to respond to events at unpredictable times..
Yet No Comments