Dependency Inversion Principle
Depend on interfaces, not on specific implementations.
What is Dependency Inversion Principle?
The Dependency Inversion Principle says important code should depend on interfaces, not on specific tools. OrderService depends on IEmailSender, not on a particular email company.
public class OrderService
{
private readonly IEmailSender email; // an interface, not SendGridClient
public OrderService(IEmailSender email) => this.email = email;
}
Level: Freelancer · More OOP terms at this level
Updated