Solid Principles

Distilled wisdom of generations of software developers.This capture decades of academic research and industry experience.

S . O . L . I . D

  • Single Responsibility Principle.
  • Open Closed Principle.
  • Liskov Substitution Principle.
  • Interface Segregation Principle.
  • Dependency Inversion Principle.

Single Responsibility Principle.

  • Each class should have only one reason to change.
  • Decouple unrelated functionalities and segregate them into standalone classes.
  • Readability, Reusability and Maintainability.
  • The most important principle in OOD.

Open Closed Principle.

  • Introduce abstractions in front of the code that will change.
  • Use only when the requirements are reasonably predictable.
  • Isolate your code from requirements changes.

Liskov Substitution Principle.

  • Importance of proper subtyping in inheritance hierarchies.
  • Follow the Seven rules.
  • Especially important for code that will be consumed by others like Frameworks & Libaries.
  • Subtypes can be safely used instead of their supertypes.

Interface Segregation Principle.

  • Clients should only depend on functionaliity they actually use.
  • Principle of least knowledge and minimal coupling.
  • Robust design, Protection from design mistakes, better readability.

Dependency Inversion Principle.

  • Governs usage of abstraction.
  • Abstractions invert source code dependencies.
  • Protection from changes, reusability, breaking dependency on external modules.