8 junio, 2024

Structured programming: characteristics, examples, advantages, applications

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 computer programs. It has become a new programming scheme that created new techniques to be able to produce programs that are safe to operate for a longer time.

Thanks to the dizzying development of computerized data processing, by the end of the 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 difficult to access and navigate with any logic, even for their own authors.

[toc]

Origin

Programmers used the “goto” command in programming languages ​​to perform conditional branching, which often led to poor readability and no logical context being preserved.

In that software crisis, the question began to be raised about whether a general and disciplined methodology could be systematically developed that would make it possible to carry out more refined programs. In 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 comprehension of computer programs.

Niklaus Wirth designed a new programming language, called Pascal, released in 1970. Since then it has been widely used to teach structured programming design.

Characteristics

This programming mode is characterized by the fact that programmers can fragment the source code of their programs into logically structured blocks, consisting of loops, logical blocks and conditional commands.

The goal of structured programming is to make programs easy to write, debug, and modify. The programs obtained are clear, orderly, understandable, without jumps.

structured programming theory

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 encouraged to apply the descending technique, also called from the top to the bottom.

– The ranges of validity and visibility of variables and data structures must be limited.

control structures

The structural theorem states 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 allows an efficient approach to functions with any degree of difficulty.

Sequence or linear structure

This structure is simply the sequence or succession of two or more operations or commands.

Decision structure or alternatives

It is the selection of a command between two possible alternatives. It is also allowed to choose between more than two alternatives.

Looping or repeating structure with an initial question

Certain commands are repeated as long as a certain condition is met. The cycle can also be performed with a counter.

Programming language independent

Structured programming is based on well-defined functional modules, ranked according to the specific nature of the problem. This programming is a method independent 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 for it.

Structured programming allows programs to be written in pseudocode, independent of machine language, close to natural, convertible into any programming language.

Structured Programming Examples

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 flow, and modularity for easy reading and code reuse.

Sequence

A list of statements can be executed 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.

– Mingle.

– Add water.

– Knead.

– Let the dough rise.

– Bake.

Repetition

A block of statements is repeated as long as a condition is true. For example: washing dishes.

Selection

A maximum of one action is chosen from several alternate conditions. For example: sort the mail.

Structured Programming in Visual Basic

Sequence

Lines or blocks of code are written and executed in a sequential order. For example, you have:

x=6

y= 12

z= x + y

WriteLine(z)

Repetition

A block of code is repeated while a condition is true. 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

Selection

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

Advantages

– These are programs that meet the needs of customers.

– Although it initially takes longer to generate the code, it often results in code that runs without errors when first run.

– It is similar to the vocabulary of words and symbols in English.

– It is easy to handle program changes due to 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. Thus, it can be run on any computer for which a suitable translator or compiler exists.

– 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 executed on any computer.

clearer programs

Structured programming reduces the chance that one function will affect another. This makes for cleaner programs to write as 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.

easy understanding

The organization helps to easily understand the programming logic, in order to understand the logic behind the programs.

It also helps newcomers of any technology company to understand the programs created by other workers in the industry, thus facilitating possible debugging of the code.

Disadvantages

– 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 may be inefficient when compared to an equivalent assembly language program.

same code repeated

The code that is written can appear in different parts of the program. It may be vulnerable to various issues due to its location. Programs have variables, which means that they can take on different values ​​in different parts of the program.

Cumbersome to change data types

The type of the data comes from many functions. Therefore, when changes occur in that data type, the corresponding change must be made in each location that acts on that data type within the program. This is a really time consuming task if the program is very large.

You can consider the case of software development, 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 shared data types with each other.

Changes to data types made by a programmer should be reflected by the other programmers on the team in the data types they have handled. Otherwise, several functions will have to be rewritten.

Applications

Structured programming has worked well for millions of programs and billions of lines of code. There is no reason to discard it.

In particular, it has worked extremely well for data crunching and number crunching programs, both of which are executed once to produce an answer.

Two characteristics tend to define well the problems that can be addressed in a purely structured way:

– The data to be handled closely coincides with the data types that are integrated into the language, being generally 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 features include many scientific, engineering, and word processing applications, in addition to 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.

object handling

Most modern programming languages ​​are structured this way: what you have in the program are objects, and most of the code consists of different methods for 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.

References

MVPS (2020). Structured programming. Taken from: mvps.net.
Alexei (2019). Structured Programming Paradigm. Medium. Taken from: medium.com.
Include Help (2020). Structured Programming, its Advantages and Disadvantages. Taken from: includehelp.com.
Tim Trott (2019). Structured Programming Languages. Lonewolf Online. Taken from: lonewolfonline.net.
OO Portal (2020). Uses and Benefits of Traditional, Structured Programming. Taken from:…

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *