Skip to content
We areTOP 1%

What are the SOLID principles?

MediumConceptOOP & SOLID
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

SOLID is a set of five object-oriented design principles that make code easier to extend, test and maintain.

  • Single Responsibility: a class should have one reason to change; keep invoice calculation separate from invoice printing.
  • Open/Closed: open for extension, closed for modification; add a new PaymentMethod subclass instead of editing a growing if-else chain.
  • Liskov Substitution: a subtype must work wherever its base type is expected without breaking behaviour; a Square that changes both sides when only the width is set breaks code written for Rectangle.
  • Interface Segregation: prefer small, focused interfaces so that clients do not depend on methods they do not use.
  • Dependency Inversion: high-level modules depend on abstractions rather than concrete classes, typically supplied through constructor injection.

More in OOP & SOLID

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account