Lecture 18: Classification of Coupling
Unit 3: Requirement Analysis and Design (4353202)
Lecture Agenda
- Recap of Cohesion
- What is Coupling?
- Why is Coupling Important?
- Levels of Coupling (from strongest to weakest)
- Examples for Each Level of Coupling
- Goal: Low Coupling
- Cohesion vs. Coupling
- Key Takeaways
Recap of Cohesion
Cohesion measures how strongly related and focused the responsibilities of a single module are. We aim for **Functional Cohesion** (strongest).
What is Coupling?
Coupling is a measure of the degree of interdependence between software modules. It describes how closely connected two modules are.
In simpler terms, it's about how much one module relies on another.
Why is Coupling Important?
- Impact of Changes: High coupling means changes in one module can force changes in many other modules.
- Reusability: Highly coupled modules are harder to reuse independently.
- Testability: Highly coupled modules are harder to test in isolation.
- Maintainability: Systems with high coupling are generally harder to maintain.
Levels of Coupling (Strongest to Weakest)
- Content Coupling
- Common Coupling
- External Coupling
- Control Coupling
- Stamp Coupling
- Data Coupling
1. Content Coupling (Strongest)
One module directly accesses or modifies the internal data or code of another module.
- Example: Module A directly changes a local variable inside Module B.
- Problem: Any change in Module B's internal structure breaks Module A. Extremely difficult to maintain.
2. Common Coupling
Modules share a common global data structure (e.g., a global variable, a shared database).
- Example: Multiple modules read from and write to the same global configuration object.
- Problem: Changes to the global data structure affect all modules using it. Hard to trace data flow.
3. External Coupling
Modules communicate with external entities (e.g., operating system, hardware, external files) through a well-defined interface.
- Example: A module that writes logs directly to a specific file path on the operating system.
- Problem: Dependency on external environment. Changes in the external interface require changes in the module.
4. Control Coupling
One module passes a control flag or parameter to another module, which then uses this flag to decide its internal logic or behavior.
- Example: Module A calls `processData(data, typeFlag)`, where `typeFlag` tells `processData` whether to sort or filter the data.
- Problem: Module A needs to know about Module B's internal logic. Reduces reusability of Module B.
5. Stamp Coupling
Modules pass entire data structures (e.g., an object, a record) to each other, even if the receiving module only needs a small part of that structure.
- Example: Passing an entire `Customer` object to a function that only needs the `customerID`.
- Problem: Module B becomes dependent on the structure of the entire `Customer` object, even if it only uses a small part.
6. Data Coupling (Weakest / Most Desirable)
Modules interact by passing only necessary data elements as parameters. Each module receives only the data it needs to perform its function.
- Example: Module A calls `calculateSum(num1, num2)`, passing only the two numbers needed for the calculation.
- Benefit: Modules are highly independent, easy to reuse, and easy to test. This is the ideal level of coupling.
Goal: Low Coupling
In software design, the goal is to achieve **Data Coupling** as much as possible. This leads to highly independent and reusable modules.
Avoid **Content**, **Common**, and **External Coupling** as they lead to tightly coupled systems that are difficult to maintain and extend.
Cohesion vs. Coupling
- Cohesion: Focuses on the internal elements of a module (how well they work together). Aim for HIGH cohesion.
- Coupling: Focuses on the relationships between different modules (how dependent they are on each other). Aim for LOW coupling.
Good Software Design = High Cohesion + Low Coupling
Key Takeaways
- **Coupling** measures the interdependence between modules.
- Lower coupling leads to **easier maintenance, testing, and reusability**.
- **Data Coupling** is the weakest and most desirable type.
- Achieving **high cohesion and low coupling** is a fundamental goal in software design.
Next Lecture
Topic: Data Flow Diagrams (DFD)
Q & A
Questions & Discussion

