SOLID Principles Overview
MediumIn plain terms
SOLID is a set of five design principles that help you write maintainable, flexible object-oriented code. They were popularized by Robert C. Martin and are language-agnostic.
S: Single Responsibility—one class, one reason to change. O: Open/Closed—open for extension, closed for modification. L: Liskov Substitution—subtypes must be substitutable for their base types. I: Interface Segregation—many specific interfaces beat one big one. D: Dependency Inversion—depend on abstractions, not concretions. Applying SOLID reduces coupling, improves testability, and makes change safer.
What you need to know
- •S: Single Responsibility
- •O: Open/Closed
- •L: Liskov Substitution
- •I: Interface Segregation
- •D: Dependency Inversion
Example
Code is language-agnostic in spirit; adapt the idea to your language:
// SOLID in one line each:
// S: One class = one job
// O: Extend via new classes, don't edit existing
// L: Subclass can replace parent
// I: Small, focused interfaces
// D: Depend on interfaces/abstractsWhy this matters
SOLID is asked in mid/senior interviews. Being able to name all five and give a one-line summary of each shows you think about design, not just code.
How it connects
SOLID applies the OOP pillars in practice: encapsulation and abstraction (SRP, OCP, DIP), polymorphism (LSP, OCP), and clear interfaces (ISP). Clean code and design patterns (later) align with SOLID.
Interview focus
Be ready to explain these; they come up often.
- ▸Name all five: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion.
- ▸One line each: one reason to change; extend not modify; subtypes substitutable; small interfaces; depend on abstractions.
- ▸Why SOLID: maintainability, testability, fewer bugs when requirements change.
Learn more
Dive deeper with these resources: