The structured approach to programming is. Software development technologies. Top-down step-by-step design

Information stage start

The development of mankind more and more prompted the greatest minds to think about the automation of some processes. The beginning of the programming stage is attributed by various sources to several periods in the interval from the beginning of the 19th to the middle of the 20th centuries. Over the decades, many techniques for writing source code have emerged. Each of them is radically different in its principles and ideas. Consider structured programming, which appeared in the 70s of the last century.

A bit of history

Before the emergence of this technique, the assembler was very common - a language operating with the simplest instructions, which were then translated into machine code that could be directly understood by the computer. This approach has been used only for writing relatively small programs. In addition, it was extremely difficult to understand someone else's code, if not impossible. But with the advent of the new methodology, the development process went much faster.

Basic principles of structured programming

Let's consider in detail the main points of the structural approach.

1. The source code has a modular structure. This means that the program is actually broken down into smaller units - functions and procedures. These routines can be called from anywhere in the development. Procedures are dedicated sections of code that have a name and perform specific actions specified by the algorithm. Functions, in addition to these capabilities, implement the calculation of some variables, and also have a return value that can be used in the main part of the program. In addition, some languages \u200b\u200bsupport recursion - a call from "itself". This can be effective for problem solving, but it often leads to a loop.

2. Top-down or bottom-up. Structured programming supports several directions. Sequential definition of goals, objectives and their implementation through the source code - a top-down approach. This technique is most understandable from the point of view of researching the written program and detecting bottlenecks. However, there is another side - the bottom-up approach. It is usually used when the exact algorithm of the program has not yet been developed, but it is already possible to write separate subroutines that implement specific actions.

3. Control elements. Structured programming has gotten rid of some of the "assembly" approaches. In low-level languages, an unconditional jump (goto) is often used, which is quite difficult to track and control. The structured approach to programming instead uses the following elements: loop, condition, and sequence.

Programming languages

With the development of this methodology, programming languages \u200b\u200bbegan to appear and develop. The structural approach is implemented by such well-known ones as Pascal (Pascal), C (C), as well as the more outdated Algol (Algol).

Epilogue

At one time, structured programming was quite widespread in the information technology environment and helped to solve the most difficult tasks at that time. However, life does not stand still, and technical progress requires fresh ideas.

Structured programming - programming methodology aimed at creating logically simple and understandable programs. Structured programming is based on the assumption that the consistency and comprehensibility of the program facilitates the development, proof of correctness, and subsequent maintenance of the program, as well as ensures its reliability.

The characteristic principles of structured programming are:

· top-down programming -a way of developing programs, in which programming is carried out by the "top-down" method, from the general to the details;

· modular programmingwhere relatively independent subtasks are programmed as separate software modules;

· Use in programming of three control structures (following, selection, repetition). The following structure assumes a natural sequence of statements execution. The choice structure is defined by the "if - then - otherwise" scheme (conditional if statement). The loop operator is mapped to the repetition structure;

· Rejection of unconditional control transfers and limited use of global variables.

Structured programming is based on a theorem that has been rigorously proven in programming theory. Its essence is that an algorithm for solving any logical problem can be composed only of structures "following , branching, cycle ". They are called basic algorithmic structures. In fact, we have adhered to the principles of structured programming in all the examples of programs considered before.

Follow is a linear sequence of actions (Fig. 2.6):

Figure: 2.6. Following

Each block can contain both a simple command and a complex structure, but it must necessarily have one input and one output.

Branching algorithmic alternative. Control is transferred to one of the two blocks depending on whether the condition is true or false. Then there is an exit to the general continuation (Fig. 2.7):

Figure: 2.7. Branching

Cycle repetition of some group of conditional actions. There are two types of loop. First loop with precondition (fig. 2.8):

Figure: 2.8. Loop with precondition

While the condition is true, the series is executed, forming the body of the loop.

The second type of cyclic structure loop with postcondition (fig. 2.9):

Figure: 2.9. Loop with postcondition

Here, the loop body precedes the loop condition. The body of the loop repeats its execution if the condition is false. The repetition ends when the condition becomes true.

Only the first type of cycle is theoretically necessary and sufficient loop with precondition. Any cyclic algorithm can be built using it. This is a more general version of the cycle than the cycle-before. Indeed, the body of the loop-before will be executed at least once, since the condition is checked after its completion. And for a loop, for now, such an option is possible when the body of the loop will not be executed even once. Therefore, in any programming language, it would be possible to limit ourselves to just a bye-loop. However, in some cases, the use of the do cycle is more convenient, and therefore it is used.

Sometimes in the literature, structured programming is called programming without goto. Indeed, with this approach, there is no place for an unconditional jump. The unjustified use of the goto operator in programs deprives it of its structure, and therefore of all the associated positive properties: the transparency and reliability of the algorithm. Although this operator is present in all procedural programming languages, it should be avoided in a structured manner.

A complex algorithm consists of basic structures interconnected. These structures can be connected in two ways: consistent and nested. This situation is similar to what we observe in electrical engineering, where any arbitrarily complex electrical circuit can be decomposed into series and parallel connected sections.

Nested algorithmic structures are not analogous to parallel-connected conductors. The analogy with nesting dolls placed in each other is more suitable here. If the block that makes up the body of the loop is itself a cyclic structure, then there are nested loops. In turn, the inner cycle can have another cycle inside it, etc. In this regard, the idea of \u200b\u200bthe depth of nesting of loops is introduced. Likewise, branches can be nested within each other.

The structural approach requires adherence to a standard in the depiction of flowcharts. You need to draw them as it was done in all the examples given. Each basic structure must have one input and one output. The non-standard block diagram is poorly readable, the clarity of the algorithm is lost.

The programming languages \u200b\u200bPascal and C are called structured programming languages. They contain all the necessary control constructs for the structural construction of the program. The structure of the external appearance of the program text gives clarity to this construction. The main technique used for this line offsets that must obey the following rules:

Constructions of the same nesting level are written at the same vertical level (starting from one position in a line);

The nested structure is written as shifted along the line by several positions to the right relative to the structure external to it.

Structural algorithmization technique it is not only a form of describing an algorithm, but it is also a programmer's way of thinking . When creating an algorithm, one should strive to compose it from standard structures. Using the building analogy, we can say that the structural methodology for constructing an algorithm is similar to assembling a building from standard sections as opposed to folding it brick by brick.

Another most important structural programming technique is the decomposition of the problem being solved into subtasks parts of the original problem that are simpler in terms of programming. Algorithms for solving such subproblems are called auxiliary algorithms. In this regard, two ways are possible in the construction of the algorithm:

“From top to bottom”: first, the main algorithm is built, then the auxiliary algorithms;

“From bottom to top”: first, auxiliary algorithms are compiled, then the main one.

The first approach is also called the sequential detailing method, the second assembly method.

The assembly method involves the accumulation and use of libraries of auxiliary algorithms implemented in programming languages \u200b\u200bin the form of subroutines, procedures, functions. With sequential detailing, the main algorithm is first built, and then calls are made to the auxiliary algorithms of the first level. After that, auxiliary algorithms of the first level are compiled, in which there may be calls to auxiliary algorithms of the second level, etc. The lowest-level helper algorithms consist only of simple commands.

The method of successive detailing is used in any design of complex objects. This is a natural logical sequence of thinking of a designer: a gradual deepening into details. In our case, we are also talking about design, but not technical devices, but algorithms. It is almost impossible to construct a sufficiently complex algorithm in any other way.

In the sequential refinement method, the original problem is analyzed first. Subtasks are highlighted in it. A hierarchy of such subtasks is built. Then algorithms (or programs) are compiled, starting with the main algorithm (main program), then auxiliary algorithms (subroutines) with a sequential deepening of the level until we get algorithms consisting of simple commands.

First step of detailing. First, we outline all the necessary subroutines, indicating only their headers (specifications). In place of the body of the subroutines, write down explanatory comments (this kind of subroutine is called a "stub"). Let's write the main part of the program. And then back to the detailed programming of procedures and functions. At the first stage of programming, instead of the body of the subroutine, we describe its purpose in the form of a comment.

  • Structural
    • Separation of responsibility:
  • Template: software based on the presentation of the program in the form of a hierarchical block structure. Proposed in the 70s of the XX century by E. Dijkstroy, developed and supplemented by N. Virt.

    In accordance with this methodology

    1. Any program is a structure built from three types of basic structures:
      • sequential execution - single execution of operations in the order in which they are written in the program text;
      • branching - one-time execution of one of two or more operations, depending on the fulfillment of some given condition;
      • cycle - multiple execution of the same operation until a certain specified condition is fulfilled (the condition for continuing the cycle).
      In a program, basic constructs can be nested within each other in an arbitrary way, but no other means of controlling the sequence of operations are provided.
    2. Repeating program fragments (or not repeating, but representing logically integral computational blocks) can be formed in the form of the so-called. subroutines (procedures or functions). In this case, in the text of the main program, instead of the fragment placed in the subroutine, the instruction is inserted subroutine call... When such an instruction is executed, the called subroutine is executed, after which the program execution continues with the instruction following the subroutine call command.
    3. The development of the program is carried out step by step, by the "top down" method.

    First, the text of the main program is written, in which, instead of each coherent logical fragment of text, a call to a subroutine is inserted that will execute this fragment. Instead of real, working subroutines, "stubs" are inserted into the program, which do nothing. The resulting program is checked and debugged. After the programmer makes sure that the subroutines are called in the correct sequence (that is, the general structure of the program is correct), the stub subroutines are sequentially replaced with actually working ones, and the development of each subroutine is carried out in the same way as the main program. Development ends when there is not a single "plug" left that would not have been removed. This sequence ensures that at each stage of development the programmer simultaneously deals with a multitude of fragments that are visible and understandable to him, and can be sure that the general structure of all higher levels of the program is correct. When maintaining and making changes to the program, it becomes clear which procedures need to be changed, and they are made without affecting parts of the program that are not directly related to them. This allows you to ensure that when you make changes and correct errors, some part of the program that is currently outside the programmer's attention will not break.

    Structured programming theorem:

    Main article: Bohm-Jacopini theorem

    Any scheme of the algorithm can be represented as a composition of nested begin and end blocks, conditional statements if, then, else, loops with a precondition (while), and there may be additional logical variables (flags).
    This theorem was formulated by the Italian mathematicians K. Bohm and J. Jacopini in 1966 and tells us how to avoid using the goto operator.

    History

    The structured programming methodology appeared as a consequence of the increasing complexity of tasks solved on computers, and the corresponding complication of software. In the 1970s, the volume and complexity of programs reached such a level that the "intuitive" (unstructured, or "reflex") development of programs, which was the norm in earlier times, ceased to meet the needs of practice. The programs became too complex to be properly maintained, so some sort of systematization of the development process and program structure was required.

    The strongest criticism from the developers of the structured approach to programming was the GOTO operator (unconditional jump operator), which was then available in almost all programming languages. Incorrect and thoughtless use of arbitrary transitions in the program text leads to confusing, poorly structured programs (the so-called spaghetti code), from the text of which it is almost impossible to understand the execution order and interdependence of fragments.

    Following the principles of structured programming made the texts of programs, even rather large ones, normally readable. The understanding of programs has become much easier, it became possible to develop programs in a normal industrial mode, when the program can be easily understood not only by its author, but also by other programmers. This made it possible to develop software systems, large enough for that time, by efforts of development teams, and to accompany these complexes for many years, even in conditions of inevitable changes in the staff.

    The structured software development methodology has been hailed as "the strongest formalization of the 1970s." Since then, the word "structural" has become fashionable in the industry, and it has begun to be used wherever and wherever it is needed. There were works on “structural design”, “structural testing”, “structural design” and so on. In general, about the same thing happened that happened in the 90s and is happening now with the terms "object", "object-oriented" and "electronic".

    Here are some of the benefits of structured programming:

    1. Structured programming allows you to significantly reduce the number of options for building a program according to the same specification, which significantly reduces the complexity of the program and, more importantly, makes it easier for other developers to understand.
    2. In structured programs, logically connected operators are visually closer, and loosely connected operators are farther away, which makes it possible to do without block diagrams and other graphical forms of displaying algorithms (in fact, the program itself is its own block diagram).
    3. Testing and debugging structured programs is greatly simplified.

    see also

    Links


    Wikimedia Foundation. 2010.

    • Mahajanapada
    • Camel

    See what "Structured programming" is in other dictionaries:

      Structured programming - methodology and technology of software systems development based on the principles of: top-down programming; modular programming. In this case, the logic of the algorithm and programs must use three basic structures: sequential ... ... Financial vocabulary

      structured programming - struktūrinis programavimas statusas T sritis automatika atitikmenys: angl. structured coding; structured programming vok. strukturelle Programmierung, f rus. structured programming, n; structured programming, n pranc.…… Automatikos terminų žodynas

      Structured programming - 46. Structured programming Structured programming Source: GOST 19781 90: Software for information processing systems. Terms and Definitions … Dictionary-reference book of terms of normative and technical documentation

      Programming - This article needs to be completely rewritten. There may be explanations on the talk page. This term has other meanings, see Programs ... Wikipedia

      PROGRAMMING - 1) the process of drawing up a program, an action plan. 2) Section of informatics, studying methods and techniques of programming. With a bit of convention, P. as a discipline is divided into: theoretical, studying mat. abstractions of programs (as objects with ... ... Physical encyclopedia

      Prototype based programming - Prototypical programming is a style of object-oriented programming, in which there is no concept of a class, and reuse (inheritance) is done by cloning an existing instance of a prototype object. ... ... Wikipedia

      Paradigm (programming) - The programming paradigm is a collection of ideas and concepts that determines the style of writing programs. The paradigm is primarily determined by the basic program unit and the very principle of achieving modularity of the program. As this unit ... Wikipedia

      Computer programming - Software Development Software Development Process Process Steps Analysis | Design | Implementation | Testing | Implementation | Maintaining Agile Models / Methods | Cleanroom | Iterative | Scrum | RUP | MSF | Spiral | ... Wikipedia

      Unstructured programming - Structured programming software development methodology, which is based on the presentation of the program in the form of a hierarchical block structure. Proposed in the 70s of the XX century by E. Dijkstroy, developed and supplemented by N. Virt. In ... Wikipedia

      Component Oriented Programming - Programming paradigms Agent-oriented Component-oriented Concatenative Declarative (contrasts with Imperative) Constraints Functional Data flow Table-oriented (spreadsheets) Reactive ... Wikipedia

    Books

    • The discipline of programming, Dijkstra E. The book was written by one of the largest foreign experts in the field of programming, known to the Soviet reader for translating his books into Russian (for example, "Structural ...

    Lecture 1. Object-oriented programming.

    Object Oriented Programming (OOP) is the dominant style when writing large programs. The main stages of the evolution of the structured approach to programming help to better understand the relationship structural approach, modular programming and OOP.

    The unit cost of creating programs has changed little until recently. With the growth of the volume of the program, the unit cost of its creation could increase nonlinearly. The time to create complex programs is proportional to the square or even the cube of the program volume. Therefore, one of the main factors determining the development of programming technology is reducing the cost of designing and creating software products (PP) or fighting the complexity of programming.

    Other factors influencing the evolution of PCB design and creation methods are:

    Changing architectures of computing facilities (CS) in the interests of increasing
    performance, reliability;

    Simplification of user interaction with aircraft and intellectualization of aircraft.
    The action of the last two factors is associated with an increase in the complexity of the aircraft software. Complexityrepresents an inherent property of programming and programs that appearsin the time and cost of creating programs, in the volume or length of the program text, the characteristics of its logical structure, set by the control transfer operators (branches, loops, subroutine calls).

    There are 5 sources of programming complexity:

    The problem to be solved;

    Programming language;

    Program execution environment;

    Technological process of collective development and creation of software;

    Striving for versatility and efficiency of algorithms and data types.

    The property of complexity cannot be eliminated, but the characteristics of its manifestation can be changed by management or organization.

    Widely used in programming fundamental principle management of complex systems, which is known to man from ancient times - devide et impera(divide and conquer, lat.) and is used in the development and design of any complex technical systems. According to the first part of this principle, when designing a complex software system, algorithmic decomposition the problem being solved.

    The purpose of decomposition is to represent the system under development in the form of interacting small subsystems (modules or blocks), each of which can be debug regardless of others. When designing a system that is divided into subsystems, you need to keep in mind much fewer details than in the absence of such a separation.


    Along with the term decomposition , also used the term structuring problems, tasks or programs. The ideas of dividing programs into relatively independent large parts that implement certain procedures and functions and form a certain hierarchy of relationships are reflected in structural approach to the development and creation of software. In programming, the structured approach appeared with the emergence of the first subroutines and functions written in procedural-oriented style. This style is based on the rule: define variables and constants that need to be stored in computer memory and describe the algorithm for their processing.

    The structural approach received its theoretical form in the early 70s in the works of theorists and practitioners of programming (A.P. Ershov, E. Yodan, N. Virt). It should be noted the emergence of structured programming, in which the idea of \u200b\u200bordering the structure of the program has found a certain reflection. Structured programming focuses on compiling programs, the structure of which is close to the "tree" of operators or blocks. The use of a tree structure as a kind of reference is explained by the fact that it is a structure that is easy to analyze and implement.

    Further development of the structural approach led to modular programming. It provides for the decomposition of an applied problem in the form of a hierarchy of interacting modules or programs. A module containing data and procedures for their processing is convenient for offline development and creation. The specialization of modules by types of processing and the presence of certain types of data in them are properties that reflect the relationship between modular programming and OOP.

    The most important tools of PCB manufacturers, which reflect almost all aspects of evolution, are programming languages.

    The programming language is initially focused on a computer and contains a set of data types, operators, operations, functions that can be quite simply translated into commands for controlling the hardware and software of the computer. In this case, it is desirable to maximize the efficiency of translation of language sentences into machine codes in the sense of minimizing the required memory, program execution time, and the cost of creating a translator. At the same time, the programming language is focused on the programmer and provides tools for modeling objects, their properties and behavior when solving applied problems in a certain subject area in the form of programs.

    The development of languages \u200b\u200bin the direction of increasing the efficiency of compiling applied programs has led to the division of languages \u200b\u200binto the following levels:

    Low level (machine-oriented languages \u200b\u200b- assembly languages),

    High level (procedural languages: FORTRAN, ALGOL,

    The level of the problem being solved (problem-oriented languages \u200b\u200b- SQL).

    Introduction data typesmarked another direction for the development of technology
    programming logic. Data typing is meant to both facilitate
    compiling programs, and to automate the identification of errors using
    data in the form of operands and actual parameters when calling functions.
    Using structured data typesallows, firstly, to simplify the work of the algorithmist when comparing the data structures of the applied problem and data processed by the functions of program modules, and, secondly, to reduce the amount of routine work of the programmer when coding the processing algorithm.

    The generalization of the concept of "data type" is classes objects (C ++), which can contain as elements not only data of a certain type, but also methods of their processing (functions).

    Thus, with the development of programming technology both in programs and in data types, the structure of the applied problem being solved was more and more adequately reflected and the corresponding integration of data and programs in modules was carried out. At the same time, programming languages \u200b\u200bwere replenished meansnecessary for descriptions similar structures. The development of ideas of abstraction and modularity led to the emergence in programming object approach .

    A person thinks in images or objects, he knows their properties and manipulates them, in accordance with certain events. The ancient Greeks had the idea that the world can be viewed in the form of objects and events. People usually have object orientedworld view. So, thinking about a telephone, a person can imagine not only its shape and color, but also the ability to call, the nature of the ringing sound and a number of other properties (depending on his technical knowledge, fantasy).

    The programming language allows you to describe the properties of modeled objects and the order of manipulation with objects or the order of their interaction, in accordance with the conditions of the problem being solved. The first programming languages \u200b\u200bwere focused on mathematical objects, on a certain model of a calculator. Therefore, they contained such constructs as variable, constant, function, formal and actual parameters. Programmers presented their programs as interacting functions and modules. The nature of the programming was procedural, with priority given to sequences of actions with data. Accordingly, programming languages \u200b\u200bsuch as FORTRAN, PL-1, C are called procedurally oriented.

    Data and subroutines were combined into modules in accordance with the logic of designers who create complex software systems for specific areas of their application. The logic of integration into modules was determined by a number of factors, among which it should be noted domain properties: data and their processing routines corresponding to a certain class of objects in the subject area were combined into a module. Thus, the string processing module contained functions for performing basic operations with strings: joining, comparing, copying, calculating the length of a string.

    The development of the idea of \u200b\u200bmodular programming is the mapping to objects of the domain (modeled objects) program constructions, called objects, object typesor classes (modeling objects). Modeling objects contain data and functions that describe the properties of the objects being modeled. Thus, data can reflect indicative or quantitative properties (mass, length, power, price), and functions reflect behavioral or operational properties (change mass, calculate power, set price). Thus, with the object approach, the integration of data and their processing functions is determined by the structure of the subject area, that is, by a set of modeled objects, their interaction within the framework of the problem being solved.

    The modeled object always appears to a person as something single, integral, although it may consist of parts or other objects. A holistic representation of an object in the form of an interconnected set of its properties or components is basic principle object approach.

    The object approach began to develop in programming in the 70s (Smalltalk, CLOS, Ada). These languages \u200b\u200bare called object. Hierarchical classification facilities and inheritance properties are the starting point for the object-oriented approach that emerged in the 1980s. One of the reasons for the relatively slow development of the object-oriented programming style is its significant difference from the procedural-oriented style.

    Structured programming represents the biggest advancement in this area to date. Despite the fact that almost everyone has a general concept about it, almost no one can give a specific and clear definition of this term. Structured programming sets the main goal of writing programs of the least complexity, forcing the programmer to think clearly, making the program easier to understand. Its text must be made so that it is readable from top to bottom. This condition is violated if there are go to statements 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, it can still be said that the presence of this operator in the program code is the most conspicuous type of structure violation. The bodies of the modules and the underlying structures used must be resistant to hardware failures, errors in programs and distortions of the original data.

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

    Simple consistency;

    Conditions or alternatives;

    Repetitions, i.e. loops and iterations.

    One or two of any kind can be used at the same time. Each structure has a single feature - a single point of transfer of control to the structure and a single point of entry into the structure. This type of construction has a disciplining and systematizing meaning.

    The simplicity of the initial constructs in structured programming prevents informational connections as well as confusing control transfers. The complexity of programs is noticeably reduced with an increase in the structure of modules, their clarity increases, and this helps to reduce the number of errors. However, structuring also has a drawback - for the beauty and clarity of the program code, one has to pay with additional memory, as well as the time required for their implementation on a computer.

    Structural programming, that is, the structure of the program texts themselves, depends entirely on what language is used for this. Of course, the question arises, which one suits best. Modern software development tools are considered the best languages \u200b\u200bfor implementing a structured approach to programming. Among the most common are Basic, Pascal and FoxBASE. For example, it is practically impossible to implement the principles laid down in the concept of structured programming. This language is focused on writing low-level programming code.

    Structured programming is fundamentally focused on communicating with people, not with machines, so it facilitates writing programs that represent a clear and simple solution to a given problem. The 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 in any way. Sometimes the use of this operator turns out to be simply necessary to exit a certain segment of a program or cycle, as well as in order to avoid the appearance of too deep forks, especially since the transition is associated with lower levels of programs. In this case, the structure of the program remains easily readable from top to bottom. The worst of the given operator has to do with going from bottom to top.

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

    Did you like the article? To share with friends: