What Are the SOLID Principles

· Category: Tech Fundamentals

Short answer

SOLID is an acronym for five design principles that make object-oriented software easier to maintain and extend.

How it works

  • Single Responsibility: A class should have one reason to change.
  • Open/Closed: Open for extension, closed for modification.
  • Liskov Substitution: Subtypes must be substitutable for their base types.
  • Interface Segregation: Clients should not depend on unused interfaces.
  • Dependency Inversion: Depend on abstractions, not concretions.

Example

Instead of a Report class that prints, saves, and emails, split it into Report, ReportPrinter, ReportSaver, and ReportEmailer.

Why it matters

Following SOLID reduces coupling, increases cohesion, and makes refactoring safer. Violations lead to fragile code that breaks unexpectedly.