0
6.0kviews
Effective Modular Design Cohesion and Coupling
1 Answer
0
161views

Cohesion: Cohesion can be defined as the degree of the closeness of the relationship between its components. In general, it measures the relationship strength between the pieces of functionality within a given module in the software programming. It is an ordinal type of measurement, which is described as low cohesion or high cohesion.

In a good module, the various parts having high cohesion is preferable due to its association with many desirable traits of the software such as reliability, re-usability, robustness and understand-ability.

On the other hand, a low cohesion is associated with the undesirable traits, including difficulty in maintaining, reusing and understanding. If the functionalities embedded in a class have much in common, then the cohesion will be increased in a system.

High cohesion leads to the increased module re-usability because the developers of the application will easily find the component they look for in the cohesive set of operations offered by the module.

The system maintainability will be increased due to logical changes in the domain effecting fewer modules. The module complexity also reduces, when there is a high cohesion in the programming.

enter image description here

i. Coincidental cohesion: the parts of a component are not related but simply bundled into a single component. Harder to understand and not reusable.

ii. Logical association: similar functions such as input, error handling, etc. put together. Functions fall in same logical class. May pass a flag to determine which ones executed. Interface difficult to understand. Code for more than one function may be intertwined, leading to severe maintenance problems. Difficult to reuse

iii. Temporal cohesion: all of statements activated at a single time, such as start up or shut down, are brought together. Initialization, clean up. Functions weakly related to one another, but more strongly related to functions in other modules so may need to change lots of modules when do maintenance.

iv. Procedural cohesion: a single control sequence, e.g., a loop or sequence of decision statements. Often cuts across functional lines. May contain only part of a complete function or parts of several functions. Functions still weakly connected, and again unlikely to be reusable in another product.

v. Communicational cohesion: operate on same input data or produce same output data. May be performing more than one function. Generally acceptable if alternate structures with higher cohesion cannot be easily identified. Still problems with reusability.

vi. Sequential cohesion: output from one part serves as input for another part. May contain several functions or parts of different functions.

vii. Informational cohesion: performs a number of functions, each with its own entry point, with independent code for each function, all performed on same data structure. Different than logical cohesion because functions not intertwined.

viii. Functional cohesion: each part necessary for execution of a single function. e.g., compute square root or sort the array. Usually reusable in other contexts. Maintenance easier.

ix. Type cohesion: modules that support a data abstraction. Not strictly a linear scale. Functional much stronger than rest while first two much weaker than others. Often many levels may be applicable when considering two elements of a module. Cohesion of module considered as highest level of cohesion that is applicable to all elements in the module.

Coupling: In software engineering, the coupling can be defined as the measurement to which the components of the software depend upon each other. Normally, the coupling is contrasted with the cohesion. If the system has a low coupling, it is a sign of a well-structured computer system and a great design.

A low coupling combined with the high cohesion, it supports the mission of high readability and maintainability. The coupling term generally occurs together with the cohesion very frequently. The coupling is an indication of the strength of the interconnection between all the components in a system. The highly coupled systems have interconnections, in which the program units depend upon each other, whereas in the loosely coupled systems made up of components that are independent of each other and have no dependence on each other.

enter image description here

1. Content Coupling: Content Coupling is the highest type of coupling which occurs when one of the module relies on the other module’s internal working. It means a change in the second module will lead to the changes in the dependent module.

2. Common Coupling: It is the second highest type of coupling also known as Global Coupling. It occurs when the same global data are shared by the two modules. In this, the modules will undergo changes if there are changes in the shared resource.

3. External Coupling: This type of coupling occurs when an external imposed data format and communication protocol are shared by two modules. External Coupling is generally related to the communication to external devices.

4. Control Coupling: In this type of coupling, one module controls the flow of another and passes information from one to another.

5. Message Coupling: This type of coupling can be achieved by the state decentralization. It is the loosest type of coupling, in which the component communication is performed through message passing.

6. Data Coupling: The modules are connected by the data coupling, if only data can be passed between them.

7. Stamp Coupling: In this type of coupling, the data structure is used to transfer information from one component to another.

Please log in to add an answer.