S — Single Responsibility Principle
What Is SOLID
5 design principles that make code easier to change, test, extend
O — Open/Closed Principle (OCP)
L — Liskov Substitution Principle
I — Interface Segregation Principle (ISP)
D — Dependency Inversion Principle
Abstract vs. Interface
Use Abstract when:
- you need base type inheritance
- Is a true “is-a” relationship
- CreditCardProcessor IS A PaymentProcessor
- PayPalProcessor IS A PaymentProcessor
Use Interface when:
- you need interchangeable implementations
- you need to define a contract
public class OrderService
{
private StripeProcessor _processor;
}
vs
public class OrderService
{
private readonly IPaymentProcessor _processor;
}
Why SOLID is important for coding?
How have you implemented SOLID at current position?