Structural programming

Structural programming is the biggest achievement in this area at the moment. Despite the fact that almost everyone has a common concept about it, almost no one can give a concrete and clear definition of this term. Structural programming has as its main goal to write programs of the least complexity, forcing the programmer to think clearly, facilitating the perception of the program. Its text must be made so that it is readable from top to bottom. This condition is violated if go to statements are encountered in the program code, since they violate the structure of the entire program segment. Despite the fact that this indicator cannot be considered the most convenient, one can still say that the presence of this operator in the program code is the most striking type of violation of the structure. The bodies of the modules and the applied basic structures must be resistant to hardware failures, errors in programs, and distortions of the source data.

The basic principles of structural programming are as follows. Any program can be easily synthesized on the basis of elementary constructions of three main types:

- simple sequence;

- conditions or alternatives;

- repetitions, i.e. loops and iterations.

Can be used one or two of any kind at the same time. Each structure has a common feature - the only point of transfer of control to the structure and the only entry point into the structure. This type of design has a disciplining and systematizing value.

The simplicity of the initial constructions in structural programming prevents the occurrence of information links, as well as confusing control transfers. The complexity of the programs decreases markedly with an increase in the structure of the modules, their visibility increases, and this helps to reduce the number of errors. However, structuring has a drawback - for the beauty and visibility of the program code, you have to pay extra memory, as well as the time required for their implementation on the computer.

Structural programming, that is, the structural nature of the program texts themselves, entirely depends on which language is used for this. Of course, the question arises, which one is best. Modern software development tools are considered the best languages ​​that implement a structural approach to programming. Among the most common are Basic, Pascal and FoxBASE. For example, in Assembler it is almost impossible to implement the principles embodied in the concept of structural programming. This language is focused on writing code at a low level.

Structural programming is basically focused on communicating with people, not with machines, and therefore contributes to writing programs that represent a clear and simple solution to the problem. A programmer must think in terms of basic structural constructs.

If we talk about the position relative to the previously mentioned go to operator, then it should be avoided wherever possible, but this should not affect the clarity of the program. Sometimes the use of this operator is simply necessary to exit some segment of a program or cycle, and also in order to avoid the appearance of too deep forks, especially since the transition is associated with lower levels of programs. At the same time, the structure of the program remains easy to read from top to bottom. The worst use case for this operator is associated with a bottom-up transition.

To facilitate reading, programs often add blank lines between sections. It is worth writing the program text with shifts so that you can read the sequence of actions and the number of attachments.

Source: https://habr.com/ru/post/K18312/


All Articles