Coupling
Coupling measures the degree of interdependence between software components. In object-oriented design, we want coupling to be as low as possible, but not lower, or we end up with software that does very little. This allows us to make changes in a component without impacting other components.
Coupling is an indication of the independence among the components. Some indicators of possible high coupling are the following code smells:
- Divergent Change
- Feature Envy
- Inappropriate Intimacy
- Message Chains
- Middleman
- Shotgun Surgery
When we talk about components in object-oriented design, we are referring to libraries, programs, packages/namespaces/modules, classes, methods, and so on.
The types of coupling categorize how we connect components and how much one component knows about other component(s).
Types of Coupling
There are two main categories of coupling that create interdependence for very different reasons:
- Interaction Coupling...