Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

Programming 2 Module 2

Uploaded by

Shella Gilo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Programming 2 Module 2

Uploaded by

Shella Gilo
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

MODULE #2

STRUCTURED PROGRAMMING

Outline:

- Top-Down Analysis
- Modular Programming
- Structure Code

Structured Programming – is a programming style which aims to improve the quality,


clarity, development time to programs that making use of block structures.

It is a better way to program as it is involve systematic organization of programs.


It aims at removing the use of go-to statements and programs as its frequent leads to
spaghetti code which leads to inefficient code which is difficult to follow and maintain.

Structured programming involves three phases namely:

1. Top-Down Analysis

As programs are written to provide a solution to any type of problem. For larger
problems, developing a programmatic solution can be complicated we might think where
to start from, how to precede where to terminate.

Top-Down Analysis is a method of problem-solving and analysis. The approach is


to subdivide the program into smaller tasks for easing the analysis.

The ideas followed are subdivision of program which means that the entire
problem is broken down into smaller parts so that it can be analyzed and an appropriate
solution can be devised.

For it hierarchy of task means that subdivided parts of the major problem are
further broken into task thus creating a hierarchy.

Advantage of top-down analysis is reduces the complexity of problem solving not limited
by a particular type of program.
1
Page
STEPS for top-down analysis:

Step One : is to define the complete scope of problem to be solved, it includes the
determination of

input - what data to be processed,

process - what to do on the input data, what type of processing is needed to be


done,

output – what information should the program produce.

Step Two : is the division of problem in two separate parts.

Step Three : is defining the scope of each subdivided parts and dividing them further into
tasks.

Step Four : repeat step three till a simple task is reached which cannot be further
subdivided.

2. Modular Programming

It is a program designing style where the program is broken into smaller


independent units called as modules and each module is developed independent of each
other, each module accomplishes one function and contains all the source code and
variables needed to accomplish that function.

A module has entry point to which the control is transferred from outside the
module. There is only one exit point from which the control is returned back to the
calling functions.

Modular programming is a solution to the problem of very large programs that are
difficult to debug and maintain.
2
Page

The advantage of doing modular programming:


- complex program is divided into smaller elements which are more manageable
multiple programmers can code various modules simultaneously thus saving
production time,
- it leads to reusable code which can be use in other programs too.-
- Debugging and finding errors is easy.

3. Developing Structure Code

Many old programming languages which use goto statements have unstructured
code, as the control of the program is altered unconditionally. Goto can be replaced by if
if-else else if ladder to write the code in a structured manner which is termed as
structured coding.

It aims at producing well organized code by making use of control transfer


statements and not goto. Usually small programs not have logic which involves altering
of the normal flow of the program but in larger programs there is a need to alter the
normal flow of execution. This alteration is done with the use of control transfer state.
It’s like if switch-case loops like for while do-while.

The advantages of structure programming are:

- It improves the problem solving process


- Better organization of program
- Generalize programming methodology
- Clear description of data and structure
- Enables development of programs which are easily modifiable and documentable

3
Page

You might also like