C# Interview Question #95
What is loose coupling, and why is it important?
SOLID, DI, Testing & Practical C# Mid-Level Intermediate
Quick Interview Answer
Loose coupling means components depend as little as practical on concrete implementation details.
Detailed Explanation
Loose coupling means components depend as little as practical on concrete implementation details.
For example, a controller depending on IProductService is less tightly coupled than one that directly constructs ProductService and its database dependencies.
Loose coupling improves testability, maintainability, substitution, and architectural flexibility. It is commonly achieved through interfaces, dependency injection, clear boundaries, and separation of concerns.
Code Example
public class OrderService
{
private readonly IPaymentService _paymentService;
public OrderService(IPaymentService paymentService)
{
_paymentService = paymentService;
}
}