S.O.L.I.D
Principles
S.O.L.I.D are the principles that need to follow when we design the software design in objects oriented language,
these principles helps to design more understandable,flexible and maintainable software product.
1.Single responsibility
A class should have one and only reason to change.If we need to change our class more often or it is more complected to
change we can use this principle.it helps to solve this problem by making one responsibility
in each class.This principle helps to reduces the number of bugs and also improve the development speed.
2.Open/Closed Principle
"Software entities should be open for intention but closed for modification". It focusing on the behavior of super class and its sub classes.
That means we can add a new functionalities without any modifications of existing code.
Eg:-when we implement a shape class (parent class)and circle,square etc. as the child classes.child classes extended with parent class
so we can extend new classes without change any of other existing classes.
3.Liskov Substitution Principle
The super class methods and properties can override to sub classes.Child class cannot give different meanings to the method
after override that method from its super class.
4.Interface Segregation Principle
Client should not implement unwanted methods.
Eg:-The shape interface has draw() and area() methods.but circle class is its child class.it wants to use only area()
method.
The goal of this principle is reduce the side effects.
5.Dependency inversion principle
High level modules should not depend on low level modules.because of this we can do any changes to low level class without do change to high level class.
But should depend on abstractions.
Eg:-In 3 tire architecture business logic layer depend on data link layer.When can change data access layer for different data bases.
These principles use to build a quality software that easy to extend,robust and reusable.
Very useful article😊😊
ReplyDelete