title | updated | permalink |
---|---|---|
SOLID |
December 8, 2016 |
/articles/oop/solid/ |
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 states that each class or module should have one and only one role or responsibility.
Open/close principle states that each class should be open for extension and at the same time closed for modification.
Liskov segregation principle states that objects should be replaceable with instances of any of their parent classes.
Interface segregation principle states that classes should not be limited and locked for accepting more of their kind.
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.