Difference Between Cohesion and Coupling (wih Comparison Chart)
Table of Contents
Cohesion and coupling are used as the categorisation method to specify the interactions within and between the software components. We know that software could contain thousands of lines of code or even more than that, which could result in an unanticipated increase in the code complexity. To stabilize the code complexity, the concept of modularisation is introduced. The modularization is the method of splitting the software into smaller isolated pieces known as modules.
Cohesion is used to describe the interaction within the modules whereas the coupling specifies the interaction between the modules.
Content: Cohesion Vs Coupling
Comparison Chart
Basis for comparison | Cohesion | Coupling |
---|---|---|
Basic | Interconnections within modules | Connectivity between modules |
Indicates | Module's relative functional strength. | Relative interdependence among the modules. |
Designing criteria | Cohesive component must emphasize on the individual task with a low interaction with other modules. | Focuses on generating low dependency between the modules. |
Type of approach | Intra-module | Inter-module |
Extent | High | Low |
Definition of Cohesion
Cohesion is the evaluation of the related functional strength of a module. In simple words, it is the measure of the amount of interaction within the module. Now, let’s understand what type of interaction within the module we are discussing here. The cohesion is all about integration where the actions are grouped in the most suitable way, actions present in the form of methods or functions. It is basically the interaction within the methods or functions inside a module. It concentrates on performing a single task within a software procedure, along with slightly interacting with the already executing procedure from another part of the program.
Cohesion is the enhancement in the concept of information hiding, which describes that the modules must be specified and designed in such a manner that the other modules can not access the information contained within the modules.
Types of Cohesion
- Coincidental cohesion: In this type of cohesion the tasks being executed have a loose relation between them. This could happen in the scenario when the functions in a module are chosen randomly.
- Logical cohesion: It implies that the performing operations have some similarity among them, then the modules are logically cohesive.
- Temporal cohesion: Temporal cohesion exists when the tasks in modules are executed in the same time span.
- Procedural cohesion: Procedural cohesion exhibits when a procedure has a part of module which contains a group of functions. These functions should be executed in order to achieve the particular result.
- Communicational cohesion: The communicationally cohesive functions belong to or works on the same data structure.
- Sequential cohesion: In this type of cohesion the module entities are serially connected which means the next entity would require the output of the first entity.
- Functional cohesion: The module is said to possess the functional cohesion when the different elements of the module are collaboratively executed to achieve single function.
Definition of Coupling
Coupling is the term used for representing the extent of interdependence between the modules existing in a software. If the massive amount of data is exchanged between the modules, then they are considered as interdependent. The software components can interact by changing another component’s code, accessing the data stored within another component, passing the data stream from one component to another, etcetera. The coupling between the modules relies on the complexity of the interface, from where the entry or reference is made to the module.
In the software design, the lowest amount of coupling should be employed. Simple connections are used among the modules to make the software easy to understand and free from the ripple effect. Ripple effect is nothing but the propagation of the errors from one to another throughout the system.
Types of Coupling
- Data coupling: When the two modules are able to interact by sharing the parameters, then they are supposed to be data coupled.
- Stamp coupling: It describes the use of composite data unit among the modules in order communication with each other.
- Control coupling: The data in one module is used to drive the control to the other module, that is control coupling.
- Common coupling: When the two modules share the data by the accessing the global data items, they possess the common coupling.
- Content coupling: The content coupling exists when the modules share the code.
Key Differences Between Cohesion and Coupling
Conclusion
Cohesion is a quantitative implication of the degree to which a module concentrates on just a thing. On the other hand, the coupling is a qualitative implication of the level to which a module is linked to other modules and the external world. In an ideal case for achieving better modularity and functional independence, the number of interactions between the modules (Coupling) must be low while the interaction within the modules (Cohesion) should be higher in extent.
ncG1vNJzZmislZi1pbXFn5yrnZ6YsrR6wqikaJyZm7OmvsSnmp5lkprBuLHEp2Scp5iawKq7zWaYp5xdmLy2vMuipaBmmKm6rQ%3D%3D