Basics of structured programming. Principles of Structured Programming

The first programs consisted of several tens - hundreds of machine instructions. Software systems and information systems included from several tens of thousands to millions of operators in high-level languages. As the volume increases software the first place in terms of influence on the speed of their development was taken by the process debugging, those. detection and correction of mistakes. Practice has shown that it is almost impossible to write a more or less large program without errors. Moreover, even during the operation of ready-made programs, errors missed during debugging are discovered. Errors fall into several categories.

The simplest one is syntax errors. They are associated with incorrect writing of language constructs and are detected immediately, at the moment when the compiler tries to translate the program into machine language

If all syntax and layout errors are corrected, the program begins execution (stage Run). However, this stage may be interrupted by an illegal operation (such as division by zero), in which case runtime errors are said to occur. (RunTime Errors). Or the program has counted to the end, but the results obtained are incorrect. This can be caused by algorithm errors, or errors in the organization of intermodule connections, errors in data type conversion, or simple errors (for example, a zero was missed when writing the number 100 and the program used 10 in the calculations).

Runtime errors are detected by solving a series of test cases (running the program), the result for which is known in advance. As a rule, the time spent searching for such errors significantly exceeds the time spent writing the program itself and correcting syntax errors. The development of the programming concept is closely related to the problem of reducing defects when writing a program.

Under development theoretical foundations structured programming, theory of proof of program correctness, evidence-based programming.

The concept of structured programming presupposes such a scientifically based approach to the construction of a program and to the capabilities of a programming language, in which the volume of possible errors. Significant development of the concept has been achieved in the structured programming language Pascal. The essence of structured programming is that data are primarily abstractions of real objects and are formulated preferably as abstract structures that may not have a concrete implementation in a programming language. In the process of constructing a program, the data representation is gradually refined following the refinement of the algorithm.

A structured programming language must provide the ability to construct your own data types. At the lowest level are the fundamental structures predefined in the language (for example: scalar types, record, array and set). Complex structures are built from fundamental structures, like molecules. Fundamental structure variables can change only the value, preserving the type or set of valid values ​​and the size they occupy. Complicated structures are characterized by a change not only in meaning, but also in the very form of representation, and in the composition of the fundamental structures included in them. Dynamic memory management is implemented at the pointer level, and dynamic data is combined into a tree structure (trees).

In addition, there are certain requirements for data typing, due to which the type of any expression or variable can be determined without the need for calculations, i.e. at the broadcast stage. In this case, you can avoid a large number of hard-to-find runtime errors by identifying them at the stage of program translation.

The concept of structured programming involves not only the use of special languages ​​and the application of a certain programming style. First of all, this is a programming philosophy, which also affects such an aspect as the methodology for training programmers.

It is noted that programming is a broad and varied activity, often requiring complex mental work. It is wrong to believe that programming can be reduced to the use of ready-made recipes based on a systematic description of the simplest blocks. Students need to develop the ability to think creatively, and the role of the teacher in showing how to do things is extremely important. Creativity is not subject to canons, methods and technologies. Careful selection and examination of representative examples is adopted as a teaching method. It is necessary to consider complex and long programs, which are often encountered in practice and are best suited for identifying that elusive but important property called style programming. Parsing long programs serves as an exercise in the art of reading them, which is no less important than the ability to write programs.

Security questions and tasks

5.1. Name and briefly describe the parts of the program team.

5.2. The basis for the ODSI operating program is ____; give its definition.

5.3. What is meant by programming in codes?

5.4. What do you know about assembly language?

5.5. What programming languages ​​are called machine-independent?

5.6. How to “translate” a program written in algorithmic language into object code that a computer can understand?

5.7. What is meant by modular programming and individual module?

5.8. What do you know about structured programming?

Structured programming is a method that involves creating improved programs. It serves to organize the design and coding of programs in such a way as to prevent most logical errors and detect those that are made.

Using the tongue high level(such as Fortran) programmers could write programs up to several thousand lines long. However, a programming language that is easily understood in short programs becomes unreadable (and unmanageable) when it comes to larger programs. Getting rid of such unstructured programs came with the creation of structured programming languages ​​in 1960. These include the languages ​​Algol, Pascal and C.

Structured programming involves precisely defined control structures, program blocks, no GOTO statements, self-contained routines that support recursion and local variables. The main thing in structured programming is the ability to break a program into its constituent elements. Using structured programming, the average programmer can create and maintain programs over 50,000 lines in length.

Structured programming is closely related to such concepts as “top-down design” and “modular programming”.

Top-down design method involves the sequential decomposition of the data processing function into simple functional elements (“top-down”).

As a result, a hierarchical diagram is constructed, reflecting the composition and subordination of individual functions, which is called functional structure of the algorithm(FSA) applications.

The functional structure of the application algorithm is developed in the following sequence:

1) the goals of automation of the subject area and their hierarchy are determined;

2) the composition of applications (processing tasks) that ensure the implementation of the set goals is established;

3) the nature of the relationship between applications and their main characteristics is clarified (information for solving problems, time and frequency of solution, etc.);

4) the data processing functions necessary to solve problems are determined;

5) decomposition of processing functions is carried out to the required structural complexity, implemented by the proposed tools.

Such an application structure reflects the most important thing - the composition and relationship of information processing functions for implementing applications, although it does not reveal the logic of the execution of each individual function, the conditions or frequency of their calls.

Decomposition must be worn strictly functional character, i.e. separate element FSA must describe complete meaningful function information processing, which involves a certain method of implementation at the program level.


Modular programming based on the concept of module logically interconnected set functional elements, designed as separate software modules. Modular programming is discussed in Section 7.

Structured programming consists in obtaining the correct program from some simple logical structures. It is based on a rigorously proven structuring theorem, which states that any regular program (with one input, one output, no loops and no unreachable instructions) can be written using only the following basic logical structures:

· linear (following);

· nonlinear (fork);

· cyclical (cycle, or repetition).

This theorem was formulated in 1966 by Bohm and Jacopini (Corrado Bohm, Guiseppe Jacopini). The main idea of ​​the theorem is to transform each part of the program into one of three basic structures or a combination of them so that the unstructured part of the program is reduced. After enough such transformations, the remaining unstructured part will either disappear or become unnecessary. The theorem proves that the result will be a program that is equivalent to the original one and uses only the basic structures mentioned.

Combinations of correct programs obtained using these three basic structures are also the right programs. By using iteration and nesting of basic structures, a program of any size and complexity can be obtained. By using only the specified structures, there is no need for unconditional jumps and labels. Therefore, sometimes structured coding is understood in a narrow sense as programming without “GOTOs”.

In the algorithmic language C (C++), the following operators are used to implement structured coding:

· compound operator;

· operator-expression;

· selection operator;

· operator-with-label;

· transition operator;

iteration operator;

· asm operator;

· declaration (in C++ only).

Follow structure(Fig. 5.1, a) is implemented by a compound operator, an expression operator, an asm operator, etc.

Compound operator, or block, is a list (possibly empty) of statements enclosed in curly braces {…} . Syntactically, a block is considered as single operator, but it affects context identifiers declared in it. Blocks can have any nesting depth.

Operator-expression is an expression followed by a semicolon. Its format is as follows:

<выражение>;

The C++ compiler executes expression statements by evaluating expressions. All side effects from this calculation are completed before the next statement begins execution. Most expression statements are assignment statements or function calls (eg printf(), scanf()). A special case is the empty statement, consisting of a single semicolon ( ; ). An empty statement does not perform any action. However, it is useful in cases where the C++ syntax expects some statement to be present, but the program does not require one (for example, an infinite for loop).

Asm operators provide programming at the assembler level (use of pointers, bitwise operations, shift operations, etc.). Using assembly language to handle routines for critical situations and repetitive operations, you can increase the speed of optimization without any improvement to the high-level language.

Fork structure(Fig. 5.1, b, c) is implemented by selection operators. Selection Operators , or flow control statements, select one of the alternative branches of the program, checking for this certain values. There are two types of selection statements: if...else and switch.

Basic operator if(Fig. 5.1, b) has next format:

if(conditional_expression)statement_if_"true" operator_if_"false";

The C++ language, unlike, for example, the Pascal language, does not have a special Boolean data type. In conditional tests, this type of role can be played by an integer variable or a pointer to a type. The conditional_expression must be written in parentheses. This expression is evaluated. If it is null (or empty in the case of a pointer type), we say that conditional_expression false(false ) ; otherwise it true(true).

If there is no else clause and the conditional expression evaluates to true, then the if statement is true; otherwise it is ignored.

If a proposal is given the if statement is false, and the conditional expression evaluates to true, then the if statement is true; otherwise the statement_if is false is executed.

Pointer conversions are performed in such a way that the value of the pointer can always be correctly compared with a constant type expression that evaluates to 0. Thus, the comparison for null pointers can be done as:

if (!ptr)... or if (ptr == 0)....

The operator_if_false and the operator_if_true can themselves be if operators, which allows you to organize any depth of nesting of conditional checks. When using nested if...else constructs, you should be careful to ensure right choice executed statements. Any ambiguity in the "else" construct is resolved by matching the else with the last if without else found at the level of the given block.

For example, the entry:

if (x == 1)

if (y == 1) puts("x=1 and y=1");

else puts("x != 1");

gives the wrong solution, since else, regardless of the writing style, is matched not with the first, but with the second if. Therefore, the correct entry for the last line should be:

else puts("x=1 and y!=1");

However, you can also implement the first construction using curly braces:

if (x == 1)

if (y = = 1) puts("x = and y=1");

else puts("x != 1");// correct solution

switch statement(see Fig. 5.1, c) uses the following basic format:

switch(switch_expression) case_statement;

It allows control to be passed to one of several case statements depending on the value of the switch_expression. Any statement in a case_statement (including the empty statement) can be marked with one (or more) case flags:

case constant_expression_i : case_statement_i;

where each constant_expression_i must have a unique integer value (convertible to the switch_expression type) within the enclosing switch statement.

It is allowed to have repeating case constants in one switch statement.

A statement can also have at most one default label:

default: default_operator;

After evaluating the switch_expression, the result is compared with one of the constant_expressions_i. If a match is found, then control is transferred to case_statement_i with the label for which the match was found. If no match is found and the default label is present, then control is transferred to the default_operator. If a match is not found and there is no default label, then no statements are executed. To stop the execution of a group of statements for a specific variant, use the break statement.

Programming languages ​​and technologies

The first programs consisted of installing key switches on the front panel computing device. Obviously, only small programs could be written in this way. With development computer equipment A machine language appeared, with the help of which the programmer could set commands, operating with memory cells, fully using the capabilities of the machine. However, using most computers at the machine language level is difficult, especially when it comes to input/output. Therefore, we had to abandon its use. For example, to read a block of data from a floppy disk, a programmer can use 16 different commands, each requiring 13 parameters, such as the block number on the disk, the sector number on the track, etc. When the disk operation completes, the controller returns 23 values ​​that reflect the presence and types of errors that need to be analyzed. “Words” in machine language are called instructions, each of which represents one elementary action for central processor, such as, for example, reading information from a memory cell. Each processor model has its own set of machine instructions, although most of them are the same. If Processor A fully understands the language of Processor B, then Processor A is said to be compatible with Processor B. Processor B will be said to be incompatible with Processor A if A has instructions that are not recognized by Processor B. In the case where it is necessary to have effective program, instead of machine languages, machine-oriented languages ​​that are close to them are used - assemblers. People use mnemonic commands instead of machine commands.

But even working with assembler is quite complex and requires special training. For example, for the Zilog Z80 processor, machine instruction 00000101 instructs the processor to decrease its register B by one. In assembly language, this will be written as DEC B.

Structured programming

The next step was taken in 1954, when the first high-level language, Fortran, was created. FORTRAN - FORmula TRANslator). High-level languages ​​imitate natural languages ​​by using some spoken language words and common mathematical symbols. These languages ​​are more convenient for humans; with their help, you can write programs up to several thousand lines in length. However, while easily understood in short programs, the language became unreadable and difficult to manage when it came to larger programs. The solution to this problem came with the invention of structured programming languages. structured programming language), such as Algol (1958), Pascal (1970), C (1972).

Structured programming involves well-defined control structures, program blocks, no goto (GOTO) instructions, self-contained subroutines, support for recursion and local variables. The essence of this approach is the ability to split a program into its component elements. Also created functional(applicative) languages ​​(Example: Lisp - English. LISt Processing, 1958) and logical languages ​​(example: Prolog - English) PROgramming in LOGic, 1972). Although structured programming, when used, has produced outstanding results, even it fails when the program reaches a certain length. In order to write a more complex (and longer) program, a new approach to programming was needed.

As a result, the principles of object-oriented programming were developed in the late 1970s and early 1980s. OOP combines best principles structured programming with powerful new concepts, the basic ones called encapsulation, polymorphism And inheritance. Examples of object-oriented languages ​​are: Object Pascal, C++, Java, etc. OOP allows you to optimally organize programs, breaking the problem into its component parts and working with each separately. A program in an object-oriented language, solving a certain problem, essentially describes a part of the world related to this problem.

By the end of the 1960s, due to the increasing complexity of programs and further development of software tools, there was a need to increase the productivity of programmers, which led to the development of structured programming. The founder of this methodology is Edsger Dijkstra, who described the basic principles of structured programming.

With the development of structured programming, the next advancement was procedures and functions. That is, if there is a task that is executed several times, then it can be declared as a function or as a procedure and simply called during program execution. The overall program code in this case becomes smaller. This contributed to the creation of modular programs.

The next advance was to combine heterogeneous data that is used in a program in a bundle into structures - these are composite data types built using other data types.

Structured programming involves well-defined control structures, program blocks, no goto (GOTO) instructions, self-contained subroutines, support for recursion and local variables. The essence of this approach is the ability to split a program into its component elements, increasing the readability of the program code.

Also created functional(applicative) languages ​​(Lisp) and logical languages ​​(Prolog)

Although the introduction of structured programming yielded positive results, even this failed when the program reached a certain length. In order to write a more complex and longer program, a new approach to programming was needed.

Object-oriented programming (OOP)

When using data structures in a program, corresponding functions for working with them are also developed. This led to the idea of ​​combining them and using them together, and classes were born.

A class is a data structure that contains not only variables, but also functions that work with these variables.



Now programming could be divided into classes and tested not the entire program, consisting of 10,000 lines of code, but the program could be divided into 100 classes and tested each class. This made writing a software product much easier.

As a result, the principles of object-oriented programming were developed in the late 1970s and early 1980s.

The first object-oriented programming language is Simula-67, in which classes first appeared. OOP concepts received further development in the Smalltalk language, which also laid the foundations for windowing systems. More recent examples of object-oriented languages ​​are Object Pascal, C++, Java, C#, etc.

OOP allows you to optimally organize programs by breaking a problem into its component parts and working with each separately. A program in an object-oriented language, solving a certain problem, essentially describes a part of the world related to this problem.

Ticket 2.

Vector programming/prototyping language MatLab

MATLAB (Matrix Laboratory) - plastic bag application programs for solving technical computing problems and the programming language of the same name used in this package.

The MATLAB language was created in the late 1970s; it was intended to work with numerical method libraries written in Fortran without knowing the language itself. The language quickly gained popularity among people involved in applied mathematics.

MATLAB Used by over 1,000,000 engineers and scientists, it works on most modern operating systems, including Linux, Mac OS, Solaris and Microsoft Windows.

The MATLAB language is a high-level interpreted programming language that includes matrix-based data structures, a wide range of functions, an integrated development environment, object-oriented capabilities, and interfaces to programs written in other programming languages.

Programs written in MATLAB are of two types - functions and scripts. Functions have input and output arguments, as well as their own workspace for storing intermediate calculation results and variables. Scripts use a common workspace. Both scripts and functions are not compiled into machine code and are saved as text files. It is also possible to save so-called pre-parsed programs - functions and scripts processed into a form convenient for machine execution. In general, such programs run faster than regular ones, especially if the function contains graphing commands.

Typical uses of MATLAB are:

· mathematical calculations (solving differential equations, calculating matrix eigenvalues, etc.)

· creation of algorithms

· modeling

· data analysis, research and visualization

scientific and engineering graphics

· application development, including graphical interface creation

The MATLAB system consists of five main parts.

· MATLAB language. It is a high-level matrix and array language with thread management, functions, data structures, I/O, and object-oriented programming features.

· MATLAB environment. It is a set of tools and devices with which the user or MATLAB programmer works. It includes tools for managing variables in the MATLAB workspace, data input and output, and creating, monitoring, and debugging M-files and MATLAB applications.

· Controlled graphics. It is a MATLAB graphics system that includes high-level commands for two- and three-dimensional data visualization, image processing, animation, and illustrated graphics. It also includes low-level commands that allow you to completely edit the appearance of graphics, just like creating a Graphic User Interface(GUI) for MATLAB applications.

· Library of mathematical functions. This is an extensive collection of computational algorithms from elementary functions such as sum, sine, cosine, complex arithmetic, to more complex ones such as matrix inversion, finding eigenvalues, Bessel functions, and fast Fourier transform.

· Software interface. This is a library that allows you to write programs in C and Fortran that interact with MATLAB. It includes facilities for calling programs from MATLAB (dynamic linking), calling MATLAB as a computational tool, and for reading and writing MAT files.

The Matlab shell consists of command line, text editor with a built-in debugger and windows with a list of files, a list of visible variables and a history of entered commands.

Matlab has a large number of packages (toolboxes) - both its own and those distributed by independent developers, often under the terms open source. Matlab includes Simulink - visual editor for modeling dynamic systems.

Ticket 3.

Graphical programming language "G" LabView

LabVIEW(English) Lab oratory V virtual I instrumentation E ngineering W orkbench is a development environment and platform for running programs written in the National Instruments G graphical programming language. LabVIEW is used in data acquisition and processing systems, as well as for managing technical objects and technological processes.

National Instruments was founded in 1976 by three founders: Jeff Kodoski, James Truchard and Bill Nowlin.

The first version of LabVIEW was released in 1986 for the Apple Macintosh; currently there are versions for UNIX, Linux, Mac OS, etc., and the most developed and popular versions are for Microsoft Windows.

LabVIEW's capabilities are similar to those of general-purpose programming systems such as Delphi. However, there are a number of important differences between them:

1. The LabVIEW system is based on the principles of graphical programming.

2. The LabVIEW system is based on the principles of object-oriented programming

3. The LabVIEW system is problem-oriented;

Each LabVIEW program is a separate virtual device, that is, a software analogue of some real or imaginary device, consisting of two interconnected parts:

1. The first part is the “front panel”, which describes the appearance of the virtual instrument and contains many information input means (buttons, switches) - controls, as well as many information visualization means - indicators.

2. The second part - “block diagram” (block diagram) describes the algorithm of operation of the virtual device.

Each VI, in turn, can use other VIs as components, just as any program written in a high-level language uses its own subroutines. Such lower-level VPs are usually called subVPs.

Important elements of the block diagram are functional nodes - built-in subVPs that are part of LabVIEW and perform predefined operations on data. Also the components of the "block diagram" are terminals(“back contacts” of front panel objects) and control structures(which are analogues of such elements text languages programming like conditional operator"IF", loop statements "FOR" and "WHILE", etc.).

Data from terminals to functional units and between different functional units transmitted using connections.

An ordinary user, as a rule, has to deal with ready-made VIs, previously developed by other specialists. Only the front panel of the VI is accessible to him, while the block diagram of the VI is hidden from his eyes. The user takes any readings, monitors the progress of some process, or even controls its progress using the front panel controls - knobs, toggle switches, buttons, etc.

So, using the LabView software environment, you can develop hardware and software systems for testing, measuring, data entry, analysis and control of external equipment.

Ticket 4.

Basics of standardization using C++ as an example. Hungarian notation.

C++- a compiled, statically typed general-purpose programming language.

In 1985, the first edition of The C++ Programming Language was published, providing the first description of the language, which was extremely important due to the lack of an official standard.

There are currently many implementations of the C++ language. Ideally, a program written in one implementation of a language should be executed in the same way on any other implementation of the same language. To ensure this condition, there are standards that describe the basic C++ constructs and the rules for their construction.

General requirements:

1) There should be no more than one C++ statement on one line

2) If a function call, operation, takes more than one line, then the hyphen should follow immediately after the comma.

3) If the expression takes several lines, move to a new one after the binary operation.

Code documentation:

1) The documentation for the source code contained in the comments should be sufficient for a complete understanding of the code for its further maintenance for both system developers and programmers

2) Each program source code file must have an introductory part containing, in the form of a comment, information about the author of the program, the file name and its contents

3) Source code must include a copyright statement if the program is being developed over several years, must be stated every year

Names:

1) Names - the name must match the property or process that it displays. The names are meaningful, understandable, based on English words.

2) Constant names should be written in capital letters only. Must not match, no matter how you set the constants. Constants can be used using the following operators: const, enum, #define.

3) You should avoid using names of variables and functions composed entirely of capital letters.

Line length: The maximum length of lines should not exceed 70 characters. Although larger monitors can display more long lines, printing devices are more limited in their capabilities.

Strategic and tactical comments:

1) Tactical comments in one line describe the operation on the next line.

2) Strategic comments describe the general purposes of a function or code fragments and are inserted into the program text as a block of several comment lines.

3) Too many tactical comments make the program code unreadable, so it is recommended to use strategic commenting.

Class name: Must correspond to the object that this class describes.

Using tabs:

1) To organize indentations, use tabs instead of spaces

2) There are no restrictions on the indentation size, but if the indentation size is more than 4 or 5 spaces, then the code may not fit the width of the page.

3) Comments must be at the level of the operator to which they correspond

4) Comments to the right of statements should be aligned with spaces rather than tabs

Source files

1) Each source file must contain the implementation of only one class or group of functions that are similar in purpose

2) Each file must have a header

3) Each .cpp file must include corresponding header files, which must contain: a) declaration of types and functions that are used by functions or methods of the class implemented in this .cpp file. b) declaration of types, variables and methods of classes that are implemented in this .cpp file.

Class names:

1) The class name must start with the letter "C", which means "class".

2) If the class name consists of several words, then each word must begin with capital letter(eg: class СConnectionPointForMyOcx)

3) Names combining more than 3 words are not recommended. Long identifiers make the program difficult to read.

4) The class name must begin with a capital letter. If the class name consists of several words, then each must begin with a capital letter, which serves as a word separator.

Hungarian notation – naming convention for variables, constants and other identifiers in program code.

Identifier names are preceded by predefined prefixes consisting of one or more characters. At the same time, as a rule, neither the presence of prefixes nor their writing are a requirement of programming languages, and each programmer (or team of programmers) can have their own.

Examples:
The prefix s (short for string) denotes a string.

The prefix a (short for array) denotes an array.

The prefix T (short for type) denotes the type.

1) If the built-in typing mechanism is not enough, the Hungarian notation allows you to write subtype variable

2) Convenient when naming objects for which the type is obvious - for example, the “OK” button can be called btnOk.

3) Hungarian notation is convenient for writing large programs in non-full-featured (by modern standards) editors without automated navigation through the text

1) Some programmers believe that the use of prefixes makes variable names less clear and thus reduces the readability of the code

2) If the name of a variable without prefixes is unknown, it is sometimes difficult to recover its prefixes.

3) When changing the type, you will need to change the variable name (not all code editors can do this automatically).

Ticket 5.

Life cycles of software tools and their standardization

The life cycle of a software is understood to mean the entire period of its development and operation (use), starting from the moment the software was conceived and ending with the cessation of all types of its use. The life cycle covers quite complex process creation and use of software. This process can be organized in different ways for different classes PS and depending on the characteristics of the development team.

Currently, there are 5 main approaches to organizing the process of creating and using software:

  • Waterfall approach. With this approach, software development consists of a chain of stages. At each stage, documents are created that are used in the next stage. The source document sets out the requirements for the software. At the end of this chain, programs are created that are included in the software.
  • Exploratory programming. This approach involves the rapid implementation of working versions of software programs that perform only a first approximation of the required functions.
  • Prototyping. This approach models the initial phase of exploratory programming up to the creation of working versions of programs intended for conducting experiments in order to establish software requirements. In the future, the development of a software system should follow the established requirements within the framework of some other approach (for example, waterfall).
  • Formal transformations. This approach involves developing formal software specifications and turning them into programs through correct transformations. This approach is based computer technology(CASE technology) software development.
  • Assembly programming. This approach assumes that the PS is constructed primarily from components that already exist. There must be some repository (library) of such components, each of which can be reused in different PSs.

The waterfall approach is mainly considered with some modifications. Firstly, because this approach deals with most software engineering processes, and secondly, because most large software systems are created within this approach.

Within the waterfall approach, the following stages are distinguished: life cycle PS:

1) development of PS,

2) production of software products (PI)

3) operation of the substation.

Let's look at each stage in more detail.

Stages of PS development: external description, design, coding, certification.

External description stage: involves the processes leading to the creation of some document, which is called external description of the software. The external description of the software begins with the analysis and determination of requirements for the software on the part of users (customer), and also includes processes for specifying these requirements.

Software design stage: covers the following processes: development of software architecture, development of software program structures and their detailed specification.

Coding stage (programming in the narrow sense) of the software: includes the processes of creating program texts in programming languages, their debugging with testing of the software.

Stage of certification of the software: the quality of the software is assessed. If this estimate is acceptable for practical use PS, then the development of the PS is considered complete. This is usually formalized in the form of some document recording the decision of the commission conducting the certification of the software.

Software product (SP)) - an instance or copy of the developed software. Production of software is the process of generating and/or reproducing (making a copy) programs and program documents of software for the purpose of delivering them to the user for their intended use. Production of PI is a set of works to ensure the production of the required quantity of PI on time.

Substation operation stage covers the processes of storage, implementation and maintenance of software, as well as transportation and use of software for its intended purpose. It consists of two parallel phases: the phase of applying the software and the phase of maintaining the software.

Application (operation) of a software system is the use of a software system to solve practical problems on a computer by executing its programs.

Maintenance of a software system is the process of collecting information about the quality of the software in operation, eliminating errors found in it, improving and modifying it, as well as notifying users about changes made to it.

Ticket 6

Imperative and declarative programming

Before talking directly about these concepts, we will tell you the definition of a programming paradigm.

Programming Paradigm– a set of ideas and concepts that determine the style of writing a program.

The main programming paradigms are:
1) imperative programming
2) declarative programming
3) functional programming
4) object-oriented programming.

There are also other programming models, but we will only look at the first two.

Programming:

1) Imperative

Programs are a sequence of actions with conditional and unconditional transitions, i.e. need to explain to the computer How need to solve the problem.

A program is a set of statements describing a fragment of a subject area or a current situation, in other words, a specification for solving a problem is specified, i.e. the programmer must describe What you need to decide what you want to get in the end.

Structured programming– a programming methodology aimed at creating logically simple and understandable programs. Structured programming is based on the assumption that the logic and understandability of a program facilitates the development, proof of correctness and subsequent maintenance of the program, and also ensures its reliability.

The characteristic principles of structured programming are:

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

· modular programming, in which relatively independent subtasks are programmed as separate software modules;

· use of three control structures when programming (follow, select, repeat). The following structure assumes a natural sequence of execution of statements. The choice structure is specified by the “if-then-else” scheme (conditional if statement). The repetition structure has a loop operator associated with it;

· refusal of unconditional transfers of control 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 the algorithm for solving any logical problem can only be composed of “following” structures , branching, cycle." These are called basic algorithmic structures. In fact, we have previously adhered to the principles of structured programming in all the program examples considered.

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

Rice. 2.6. Following

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

Branching algorithmic alternative. Control is transferred to one of two blocks depending on the truth or falsity of the condition. Then the general continuation occurs (Fig. 2.7):

Rice. 2.7. Branching

Cycle repetition of a certain group of actions according to a condition. There are two types of cycle. First loop with precondition (Fig. 2.8):

Rice. 2.8. Loop with precondition

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

Second type of cyclic structure cycle with postcondition (Fig. 2.9):

Rice. 2.9. Loop with postcondition

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

Theoretically, only the first type of cycle is necessary and sufficient loop with precondition. Any cyclic algorithm can be constructed using it. This is a more general version of a loop than a before loop. In fact, the body of the to-loop will definitely be executed at least once, since the condition is checked after completion of its execution. But for a loop, it is possible that 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 while-loop. However, in some cases the use of a loop-do 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 unconditional transition. Unjustified use of the goto operator in a program deprives it of structure, and therefore of all the associated positive properties: transparency and reliability of the algorithm. Although this operator is present in all procedural programming languages, however, adhering to a structural approach, its use should be avoided.

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 see in electrical engineering, where any no matter how 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 inside each other is more suitable here. If the block that makes up the body of the loop is itself a cyclic structure, then nested loops occur. In turn, the inner loop can have another loop inside it, etc. In this regard, an idea of ​​the depth of nesting of loops is introduced. In the same way, branches can be nested within each other.

The structural approach requires adherence to a standard in the depiction of flowcharts of algorithms. They need to be drawn as was done in all the examples given. Each basic structure must have one input and one output. A non-standard flowchart is difficult to read, and the clarity of the algorithm is lost.

The programming languages ​​Pascal and C are called structured programming languages. They contain all the necessary control structures for the structural construction of the program. Structuring gives clarity to this construction. appearance program text. The main technique used for this line shifts, which must obey the following rules:

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

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

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

Another important technological technique of structured programming is the decomposition of the problem being solved into subtasks simpler parts of the original problem from a programming point of view. Algorithms for solving such subproblems are called auxiliary algorithms. In this regard, there are two possible ways to construct the algorithm:

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

“bottom-up”: 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 ​​in the form of subroutines, procedures, and functions. With sequential detailing, the main algorithm is first built, and then calls to auxiliary algorithms of the first level are added to it. After this, auxiliary algorithms of the first level are compiled, which may contain calls to auxiliary algorithms of the second level, etc. The lowest level auxiliary algorithms consist only of simple commands.

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

In the sequential detailing method, the original problem is first analyzed. It identifies subtasks. A hierarchy of such subtasks is constructed. Then algorithms (or programs) are compiled, starting with the main algorithm (main program), then auxiliary algorithms (subroutines) with successive 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 headings (specifications). In place of the body of the subroutine, we will write explanatory comments (this type of subroutine is called a “stub”). Let's write the main part of the program. And then we will return to detailed programming of procedures and functions. At the first stage of programming, instead of the body of the subroutine, we will describe its purpose in the form of a comment.