Effective Modular Design (Functional Independence): –
1. Cohesion: –
“The degree to which all elements of a component are directed towards a single task and all elements directed towards that task are contained in a single component”.
It Describe the nature of intersection within the software module.we should always try for high cohesion in our program structure.
1) At the low end of the program structure we encounter a module that performs a set of task that relate to each other loosely means no relationship between component then all such modules are called coincidentally cohesive.
2) A module that performs task that are related logically.
Example: function => output anything
- Perform output operations :
- Output text to screen
- Output line to printer
- Output record to file
3) When a module contains task that are related by the fact that all must be executable with the same span of time then the module exhibit temporal cohesion.
4) Levels of cohesion are relatively close to one another in the degree of module independence when processing elements of a modules are related and must be executed in specific order then it is known as a procedural cohesion.
5) When all processing elements concentrate on one area of a data structure then it is known as a communicational cohesion.
2. Coupling: –
High coupling makes modifying parts of the system difficult, e.g., modifying a component affects all the components to which the component is connected.
Coupling is a measure of interconnection among modules in a software structure. Coupling depends on the interface complexity between modules. The point at which entry or references made to a module and what data passes across the interface. In software design we should try far lowest possible coupling.
- If modules share common data, it should be minimized
- Few parameters should be passed between modules in procedure calls [recommended 2 – 4 parameters ]
- Types of coupling, from strongly coupled (least desirable )
- weakly coupled (most desirable) :
1) Content coupling
2) Common coupling
3) External coupling
4) Control coupling
5) Stamp coupling
6) Data coupling
1. Content coupling (should be avoided)
- module directly affects the working of another module
- occurs when a module changes another module’s data or when control is passed from 1 module to the middle of another (as in a jump)
2. Common coupling
- 2 modules have shared data
- occurs when a number of modules reference a global data area
- Eg. In our Example Module c,g,k.
3. External coupling
- Modules communicate through an external medium (such as file)
4. Control coupling
- 1 module directs the execution of another module by passing the necessary control information
- accomplished by means of flags that set by one module and reacted upon by the dependent module
- Eg. In our Example Module d
5. Stamp coupling
- Occurs when complete data structures are passed from 1 module to another
- The precise format of the data structures is a common property of those modules
- Eg. In our Example between Module a and b.
6. Data coupling (low coupling)
- Only simple data is passed between modules
- 1 to 1 correspondence of items exists
- Eg. In our Example between Module a and c.