Modular Design of a Programs
One of the key concepts in the application of programming is the design of a program as a set of units referred to as blocks or modules. A style that breaks large computer programs into smaller elements called modules. Each module performs a single task; often a task that needs to be performed multiple times during the running of a program. Each module also stands alone with defined input and output. Since modules are able to be reused they can be designed to be used for multiple programs. By debugging each module and only including it when it performs its defined task, larger programs are easier to debug because large sections of the code have already been evaluated for errors. That usually means errors will be in the logic that calls the various modules. Languages like Modula-2 were designed for use with modular programming. Modular programming has generally evolved into object-oriented programming.
Programs can be logically separated into the following functional modules:
1. Initialization
2. Input
3. Input Data Validation
4. Processing
5. Output
6. Error Handling
7. Closing procedure
Basic attributes of modular programming:
1. Input
2. Output
3. Function
4. Mechanism
5. Internal data
Control Relationship between modules:
The structure charts show the interrelationships of modules by arranging them at different levels and connecting modules in those levels by arrows. An arrow between two modules means the program control is passed from one module to the other at execution time. The first module is said to call or invoke the lower level modules.There are three rules for controlling the relationship between modules.
1. There is only one module at the top of the structure. This is called the root or boss module.
2. The root passes control down the structure chart to the lower level modules. However, control is always returned to the invoking module and a finished module should always terminate at the root.
3. There can be more than one control relationship between two modules on the structure chart, thus, if module A invokes module B, then B cannot invoke module A.
Communication between modules:
1. Data: Shown by an arrow with an empty circle at its tail.
2. Control: Shown by a filled-in circle at the end of the tail of the arrow.
Module Design Requirements:
A hierarchical or module structure should prevent many advantages in management, developing, testing and maintenance. However, such advantages will occur only if modules fulfill the following requirements.
Coupling: In computer science, the coupling is considered to be the degree to which each program module relies on other modules, and is also the term used to describe connecting two or more systems. Coupling is broken down into the loose coupling, tight coupling, and decoupled. Coupling is also used to describe software as well as systems. Also called dependency.
Post A Comment:
0 comments: