Section 3.10
Programming In QuickBASIC
3.10 Program Structure
Good programs come from good design; good program design comes from giving sufficient
thought and effort in early stages of programming.
- Maintainable
- Reliable
- Transferable
Before we start writing code we must:
- Be clear in our own minds' about what we are trying to accomplish.
- Work out for ourselves how the task should be done.
The steps of structured programming are:
- Understand the problem.
- Plan the solution.
- Develop the methods (pseudo code, flow diagrams).
- Write the program.
- Testing
- Documentation for steps 1 to 5.
If an error is discovered at stage 5 then it is important to go back to earlier
stages to correct it.
Data
The output data, input data and processing requirements need to be understood
in order to produce a method for solving a problem.
3.10.1 Top-Down Programming
Top-down programming involves taking a big problem and braking it down into
smaller tasks. Each smaller task is broken down further.
We keep braking down tasks into sub-tasks until each sub-task is sufficiently
simple to be written as a self-contained module.
3.10.2 Advantages Of Modular Programming
-
Re-usability - Some modules will be standard
subprograms used again in different programs or parts of the
same program.
-
Ease Of Understanding - Each module of code is
small enough to be understood. Therefore it is easier to debug,
especially if its purpose is clearly defined and documented.
-
Maintainabilty - Any modules in need of
maintanence can be quickly identified and changed.
-
Project Speed - A team of programmers can work on
different modules concurrently.
-
Suitable Assigning Of Tasks - The more experienced
programmers can be given more complexd modules to write. The junior
programmers can work on the modules that are easier to code.
-
Ease of Testing - Modules can be tested
independently.
-
Programmer Replacement - If a programmer leaves
part way through a project, it is relatively easy for a new
programmer to take over a self-contained module.
-
Ease Of Project Management - A large project
becomes easier to monitor and control.
3.10.3 Botton-Up Programming
Bottom-up design involves solving parts of the problem individually, tackling
the easiest parts first and thereby gaining an understanding of the whole
problem.
Disadvantages
- The parts of the program may not fit together well.
- Considerable reprogramming may be required.