SOLID is a collection of good programming practices for object oriented programming and consists of 6 principles. These aren’t the rules you should be following strictly everywhere. These are more like best practices you should use if possible and understand. If there will be better practices found and developed besides these, they will be extended or explained in a separate chapters also.
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 classes can use the abstraction and extend it accordingly.
The following resources are advised to read beside this article to get different explanation and to know more about the SOLID principles.
Content of this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. Code snippets in examples are published under the CC0 1.0 Universal (CC0 1.0). Thanks to all the contributors.