Coupling Metrics in Software Testing
Coupling Metrics in Software Testing
In software engineering, maintaining a well-structured and maintainable codebase is essential. One important aspect of evaluating software design is understanding how different parts of a system interact with each other. This is where *Coupling Metrics* come into play. These metrics help us measure the degree of interdependence between software modules or classes, which can affect modularity, testability, and maintainability.
What is Coupling Metrics?
Coupling metrics are quantitative measures that assess how strongly one module or class is connected to others. Lower coupling is usually desired as it means fewer dependencies between modules, leading to better modular design. High coupling can indicate tight interdependencies that may hinder code flexibility and reusability.
Coupling increases complexity, reduce encapsulation and limits reusability. High values of coupling metrics is an indication that the classes under test requires high number of stubs for testing.
Types of Coupling Metrics
The following table lists and describes common coupling metrics used to evaluate object-oriented systems:
Coupling Metric | Description |
---|---|
Coupling Between Objects (CBO) | Measures the number of classes to which a class is coupled. IT is the count of the number of other classes to which the class is coupled.
A high CBO value indicates high dependency, which can increase complexity. |
Data Abstraction Coupling (DAC) | Counts the number of Abstract Data Types (ADTs) defined in a class. DAC is the number of ADTs defined in the class
Higher values may imply rich interactions with user-defined data structures. |
Message Passing Coupling (MPC) | Counts the number of messages (method invocations) sent out from a class. A higher MPC indicates more interactions with other classes. |
Response For a Class (RFC) | Represents the number of methods that could potentially be executed in response to a message received by an object. High RFC suggests increased complexity. |
Fan-In | Measures the number of modules or classes that call or use a given module. Higher Fan-In suggests high reuse, which can be beneficial. |
Fan-Out | Measures the number of modules or classes that are called by a given module. Higher Fan-Out may indicate higher dependency and reduced modularity. |
Information-Flow-based Coupling (ICP) | Counts the number of input and output parameters used by a module. It reflects how much data is shared between modules. |
Import Coupling (IHICP) | Measures the degree to which a class depends on other classes by importing their definitions. It indicates the external dependence of the class. |
Non-Import Coupling (NIHICP) | Measures the coupling that exists without explicit imports, such as method calls through interfaces or reflection. Indicates indirect dependency. |