What is loose coupling and why is it desirable?

Answer

Loose coupling means that a class depends on an abstraction (interface) of another class rather than its concrete implementation. class OrderService { constructor(private db: DatabaseInterface) {} }OrderService only knows the DatabaseInterface contract, not the specific implementation. Loose coupling is desirable because it enables: (1) Testability — you can inject a mock database in tests; (2) Flexibility — you can swap implementations without modifying the consumer; (3) Parallel development — teams can work on different implementations simultaneously; (4) Reusability — loosely coupled modules can be used in different contexts. DIP is the SOLID principle most directly responsible for promoting loose coupling.