To make the design clean, Every programmer must follow the five basic principles of object-oriented programming and design.
S.O.L.I.D is an acronym for the first five object-oriented design(OOD) principles by Robert C. Martin, popularly known as Uncle Bob.
S.O.L.I.D means:
Single-responsibility principle: One class should have one and only one responsibility.
It means a class should have only one job.
S.O.L.I.D is an acronym for the first five object-oriented design(OOD) principles by Robert C. Martin, popularly known as Uncle Bob.
S.O.L.I.D means:
- S – Single-responsibility principle
- O – Open-closed principle
- L – Liskov substitution principle
- I – Interface segregation principle
- D – Dependency Inversion Principle
Single-responsibility principle: One class should have one and only one responsibility.
It means a class should have only one job.
Open-closed principle: Objects or entities should be open for extension and closed for modification.
Liskov substitution principle: Sub types must be substitutable for super type i.e. methods or functions which uses super class type must be able to work with object of sub class without any issue.
Interface segregation principle: Clients should not be forced to implement unnecessary methods which they will not use.
Dependency Inversion Principle: High level modules should not depend on low level modules. Both should depend on Abstractions.
No comments:
Post a Comment