INTRODUCTION OF STRUCTURED PROGRAMMING CONCEPTS
Structured Programming is a method of planning programs that avoids the branching category of control structures.
structured programming: A technique for organizing and coding computer programs in which a hierarchy of modules is used, each having a single entry and a single exit point, and in which control is passed downward through the structure without unconditional branches to higher levels of the structure. Three types of control flow are used: sequential, test or selection, and iteration.
Software engineering is a discipline that is concerned with the construction of robust and reliable computer programs. Just as civil engineers will use tried and tested methods for the construction of buildings, software engineers will use accepted methods for analysing a problem to be solved, a blueprint or plan for the design of the solution and a construction method that minimises the risk of error. The discipline has evolved as the use of computers has spread. In particular, it has tackled issues that have arisen as a result of some catastrophic failures of software projects involving teams of programmers writing thousands of lines of program code. Just as civil engineers have learned from their failures so have software engineers.
THE TENENTS OR PRINCIPLES OF STRUCTURED PROGRAMMING:
- Make flow of control as easily understood as possible. (Emphasis on use of Control Structures). - Build your program from top-down. Decompose the problem into smaller and smaller pieces. (Top down development (Modularization)) - Avoid repeating the same code, can fix code in one place.
The top-down approach design was based on the following method:
■ To solve a large problem, break the problem into several pieces and work on each piece separately; ■ to solve each piece, treat it as a new problem that can itself be broken down into smaller problems; ■ repeat the process with each new piece until each can be solved directly, without further decomposition.
The following are simple examples of the structured programming approach to problem solving.
Add 23 and 35
- no further refinement is required.
Turn on a light bulb
Sub-problem 1: locate bulb (one task, one action)
Sub-problem 2: depress switch
Write a program for a computer to execute to display the average of two numbers entered through a keyboard connected to the computer. The average is to be displayed on a VDU that is also connected to this computer.
Top level:0. Display average of two numbers entered through keyboard
Next level:0.1. Get two numbers through keyboard
0.2. Calculate average of these two numbers
0.3. Display average on VDU
The three steps in next level can now be coded in a programming language such as Pascal.
Advantages of the Top-Down Design Method
• It is easier to comprehend the solution of a smaller and less complicated problem than to grasp the solution of a large and complex problem. • It is easier to test segments of solutions, rather than the entire solution at once. This method allows one to test the solution of each sub-problem separately until the entire solution has been tested.
• It is often possible to simplify the logical steps of each sub-problem, so that when taken as a whole, the entire solution has less complex logic and hence easier to develop. • A simplified solution takes less time to develop and will be more readable. • The program will be easier to maintain.
USE OF CONTROL STRUCTURE
The mechanisms that allow us to control the flow of execution are called control structures.
There are four main categories of control structures these are Sequential, Selection, Iteration, and Branching.
Structured programming is also a method of planning programs that avoids the branching category of control structures.
Sequence – Refers...