Presentation is loading. Please wait.

Presentation is loading. Please wait.

Modular Design Using Subroutines (functions later)

Similar presentations

Presentation on theme: "Modular Design Using Subroutines (functions later)"— Presentation transcript:

1 Modular Design Using Subroutines (functions later)

2 Try to make a complicated problem more understandable by dividing it into smaller, less complex sub-problems aka stepwise refinement. Stepwise refinement is related to top-down design which means that the more general tasks occur near the top of the design and more specific tasks occur below. Structured programming enhances programming productivity. Their use leads to programs that are easier to read and maintain. Programs contain fewer errors, which are easier to find and correct. There is less chance of generating new errors in the future. The goal of top-down design is to break a problem into individual tasks, or modules, that can easily be transcribed into pseudocode, flowcharts, or a program.

3 The top modules manipulate the modules beneath them. While the higher-level modules control the flow of the program, the lower-level modules do the actual work. Some subtasks in the third row do not require further refinement. The most complicated subtask, the computation of the monthly payment, has been broken down further. This task is carried out by applying a standard formula found in finance books.

4 Structured Programming Sequence Selection Repitition

5 Why use Structured Programming? Easy to write - programmer develops small portion of the whole at a time and dont have to worry about the bigger picture. The work can be divided among several programmers. It was proven that structured programs require significantly less time to write. Code is reusable saving time and reliability is guaranteed. Easy to debug - because each procedure is relatively small. Many times procedures are checked against other dummy procedures or calls, just to make sure that the procedure is working. Easy to understand - the interconnections of the procedures says a lot about the modular design of the program. The meaningful procedure names, along with relevant comments, identify the tasks performed by the modules. The meaningful variable names help the programmer to recall the purpose of each variable. Easy to change – since a structured program is self-documenting and relatively easy to deduce. Modifying a structured program often amounts to inserting or altering a few procedures rather than revising an entire complex program.

6 Do statement Test something Do statement Subprocedure or Function

7 Do statement Subprocedure or Function

Download ppt "Modular Design Using Subroutines (functions later)"

Similar presentations

Ads by Google