By Karol Bocian | February 12, 2020


SOLID is a basic concept in object-oriented programming. It was introduced by Robert C. Martin, who gathered together five rules in one concept: SOLID. It is an acronym of 5 principles for good object-oriented programming:

  • Single responsibility principle
  • Open/closed principle
  • Liskov substitution principle
  • Interface segregation principle
  • Dependency inversion principle

Single responsibility principle

Every class should have only one responsibility (every class should have only one reason to change) — one purpose of existence.

Open/closed principle

All classes should be open for enlargement and closed for modifications.

Liskov substitution principle

The application should work correctly when we put in the base class place every derived class.

Interface segregation principle

Many small and dedicated interfaces are better than few and general.

Dependency inversion principle

High-level modules should not depend on low-level modules, but the dependence should result from abstraction.


  • Better code readability.
  • Higher quality.
  • Cheaper maintenance.
  • Fewer bugs during development.
  • Easier testing.
  • Easier developing.
  • Lack of god-classes.


  • Bigger effort during developing.


Use SOLID principles everywhere you can. These are the best practices. In special situations allow yourself to not use these rules to write code faster. Despite breaking SOLID, try to write good code.

All posts from mini project: Learn SOLID and OOP principles:


Main image


One thought on “SOLID

Leave a Reply

Your email address will not be published. Required fields are marked *