SOLID & Design Patterns Interview Question #13
What is coupling in software design?
SOLID Principles, Design Fundamentals, Repository, Factory, Strategy & Decorator Junior Beginner
Quick Interview Answer
Coupling describes how strongly one module depends on the details of another. Tight coupling makes changes ripple across the system, while loose coupling allows components to evolve with fewer direct dependencies.
Detailed Explanation
Coupling describes how strongly one module depends on the details of another. Tight coupling makes changes ripple across the system, while loose coupling allows components to evolve with fewer direct dependencies.
Interfaces, encapsulation, events, dependency injection, and well-defined boundaries can reduce unnecessary coupling. Zero coupling is neither realistic nor desirable because collaborating components must communicate.
Code Example
public interface IEmailSender
{
Task SendAsync(string to, string subject);
}
public class NotificationService
{
private readonly IEmailSender _sender;
public NotificationService(IEmailSender sender) => _sender = sender;
}