Coupling is the degree of dependency between classes or modules.
It defines how much one class knows about another.

Low Coupling = Good (loose dependency)
High Coupling = Bad (tight, rigid dependency)

Key Concepts

TypeDescription
Tight CouplingClasses are heavily dependent on each other
Loose CouplingClasses interact through abstractions/interfaces

Example

Tight Coupling
class Engine {
    void start() { ... }
}
 
class Car {
    Engine engine = new Engine(); // hard-coded dependency
    
    void startCar() {
        engine.start();
    }
}
Loose Coupling
interface Engine {
    void start();
}
 
class PetrolEngine implements Engine {
    public void start() { ... }
}
 
class Car {
    Engine engine;
    
    Car(Engine engine) {
        this.engine = engine;
    }
    
    void startCar() {
        engine.start(); // depends on abstraction
    }
}

Comparison

Cohesion vs Coupling

ConceptGoal
CohesionKeep a class focused
CouplingMinimize clas interdependence

Real-World Analogy

Tight coupling: TV remote only works with one TV model
Loose coupling: Universal remote works with any brand

Tip

Loose coupling + high cohesion = solid design.
Mention coupling when discussing interfaces, dependency injection or SOLID principles.


Parent: _Design Principles