Prerequisite – Coupling and Cohesion Coupling simply means to connect two or more things together. It means the pairing of two things. It actually measures the degree of independence between two things and how closely two things are connected or represent the strength of the relationship between them. Module coupling means to couple two to more modules with each other and with the outside world. It generally represents how the modules are connected with another module and the outside world. Coupling is related to cohesion. Cohesion means that the cohesive module performs only one task or one thing in the overall software procedure with a small amount of interaction with other modules. With the help of cohesion, data hiding can be done. Low coupling correlates with high cohesion and high coupling correlates with low cohesion. Lower will be the coupling, higher will be the cohesion and better will be the program and these programs can be said as functionally independent of other modules. Low coupling minimizes the “ripple effect (spreading results of any action or error or failure)” which means it reduces the effects of changes in one module that cause errors in other modules. The main aim or goal of module coupling is to make efforts to achieve or obtain the lowest possible coupling among modules in software design. The coupling is said well if it reduces the ripple effect, the cost in program changes, testing, and maintenance.
Types of Coupling : These are following types of coupling –
- Data Coupling – Data coupling simply means the coupling of data i.e. interaction between data when they are passed through parameters using or when modules share data through parameters. When data of one module is shared with other modules or passed to other modules, this condition is said to be data coupling.
- Control Coupling – Control coupling simply means to control data sharing between modules. If the modules interact or connects by sharing controlled data, then they are said to be control coupled. The controlled coupling means that one module controls the flow of data or information by other modules by them the information about what to do.
- Common Coupling – Common coupling simply means the sharing of common data or global data between several modules. If two modules share the information through global data items or interact by sharing common data, then they are said to be commonly coupled.
- Content Coupling – Content coupling simply means using of data or control information maintained in other modules by one module. This coupling is also known as pathological coupling. In these coupling, one module relies or depends upon the internal workings of another module. Therefore, if any changes have to be done in the inner working of a module then this will lead to the need for change in the dependent module.
- Stamp Coupling – Stamp coupling simply means the sharing of composite data structure between modules. If the modules interact or communicate by sharing or passing day structure that contains more information than the information required to perform their actions, then these modules are said to be stamp coupled.
- External Coupling – The external coupling means the sharing of data structure or format that are imposed externally between the modules. External coupling is very important but there should be a limit also. It should be limited to less number of modules with structures.
- Message Coupling – Message coupling means that modules interact with each other by sending or receiving messages instead of directly accessing each other’s data or functions. This type of coupling reduces the dependency between modules and makes the system more modular and maintainable.
- Data-Content Coupling – This type of coupling occurs when one module uses data elements or variables directly from another module. It is similar to content coupling but specific to data variables only.
- Semantic Coupling – This type of coupling occurs when two modules are related semantically or logically, and their functions are related to each other. It is a desirable type of coupling as it leads to a better-designed system.
- Temporal Coupling – Temporal coupling occurs when two or more modules must be executed in a specific order or time. For example, a database must be initialized before data can be retrieved from it. This type of coupling should be minimized to reduce system complexity and improve maintainability.
- Data-Structure Coupling – Data-structure coupling occurs when two or more modules share a common data structure, but only part of that structure is used by each module. This type of coupling can lead to unnecessary dependencies and should be avoided if possible.
- Functional Coupling – Functional coupling occurs when two or more modules are tightly coupled due to their shared functionality or task. This type of coupling can be beneficial in certain cases, but it can also lead to a lack of flexibility and increased complexity.