SOLID is a collection of good programming practices for object oriented programming and consists of 6 principles. These aren’t rules that you should be following strictly everywhere. These are more like best practices you should use when possible and understood. If there are better practices than these found and developed at some point in the future, they too will be extended and explained in separate chapters.

SOLID stands for:

  • S as single responsibility principle
  • O as open/close principle
  • L as Liskov segregation principle
  • I as interface segregation principle
  • D as dependency inversion principle

Single Responsibility Principle (SRP)

Single responsibility principle states that each class or module should have one and only one role or responsibility.

Open/Close Principle (OC)

Open/close principle states that each class should be open for extension and at the same time closed for modification.

Liskov Segregation Principle (LSP)

Liskov segregation principle states that objects should be replaceable with instances of any of their parent classes.

Interface Segregation Principle (ISP)

Interface segregation principle states that classes should not be limited and locked for accepting more of their kind.

Dependency Inversion Principle

Dependency inversion principle states that classes should depend on abstractions rather than only certain class dependencies. Abstraction should be implemented without detailed functionality so that classes can use the abstraction and extend it accordingly.

See also

The following resources are advised to read beside this article to get different explanations and to know more about the SOLID principles.