Solid Principles
Solid Principle :
S - Single Responsibility
O- Open / Closed Principle
L - Liskov Substitution
I - Interface Segregation
D - Dependency Inversion
S - Single Responsibility Principle
A class should have only one reason to change, meaning a class should have only one job.
Example : For software development we have multiple people doing different thing like designer do designing, tester do testing and developer do development.
O - Open / Closed Principle
Open for extension / Closed for modification
Example: All smart phones have app stores and these app stores let you extend the base functionality of the phone. Via the App Store, you can extend the phones capabilities to allow you to manage your todo list, play video games. It's not as that Apple Google and Microsoft put the OS source code up on Github and invite you to dive in and start building games and flashlight functionality. Rather they make the core phone functionality closed for modification and they open it to an extension.
L - Liskov Substitution Principle
Child class should be able to substitute parent class
Example: A farmer son should inherit farming skills from his father and should be able to replace his father if needed.
I - Interface Segregation Principle
Many client specific interfaces are better then one general interface
Do not force any client to implement interface which is irrelevant to them.
Example: Menu should be different for different type of customer.
D - Dependency Inversion
High level objects should not depend on low level implementations
Example: TV needs battery but it doesn't say which brand of battery, you can use any AA battery you want.
Main Motive - Decoupling the Dependencies
Comments
Post a Comment