शब्दकोश · प्रोग्रामिंग

SOLID Principles

SOLID is a set of five object-oriented design principles aimed at making software easier to understand, extend and maintain.

अपडेट: अक्टूबर 6, 2026

SOLID is an acronym for five object-oriented design principles popularized by Robert C. Martin, intended to keep code flexible and maintainable.

  1. Single responsibility: a class should have one reason to change.
  2. Open/closed: code should be open for extension but closed for modification.
  3. Liskov substitution: subtypes must be usable wherever their base type is expected.
  4. Interface segregation: prefer small, focused interfaces over large general ones.
  5. Dependency inversion: depend on abstractions, not concrete implementations.

Why it matters

The principles reduce coupling and make classes easier to test and replace. Dependency inversion underlies dependency injection, and single responsibility keeps classes small. They are guidelines rather than laws: followed dogmatically they can produce excessive interfaces and layers, and they are described mainly in class-based languages.

Example

A report class that fetches data, formats it and emails it breaks single responsibility. Splitting it gives ReportData, ReportFormatter and Mailer. If Mailer is an interface, tests can pass a fake mailer, which is dependency inversion in practice.

Common mistakes

  • Creating an interface for every class with only one implementation.
  • Reading single responsibility as "one method per class".
  • Violating Liskov by overriding a method to throw "not supported".

Get notified when this term updates

Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.

यह पेज सामान्य जानकारी है, जिसे हमारी संपादकीय टीम ने लिखा है और दस्तावेज़ीकरण बदलने पर अपडेट किया जाता है। सर्वर और प्रदाता अलग-अलग होते हैं, इसलिए बदलाव पहले सुरक्षित तरीके से जाँचें। देखें: संपादकीय नीति और अस्वीकरण.