SOLID is one of the most popular sets of design principles in object-oriented software development. The goal of the SOLID principles is to reduce dependencies so that engineers change one area of software without impacting others. These principles outline best practices for designing software while keeping in mind the project's long-term maintenance and expansion. Adopting these techniques can also help avoid code smells, restructure your code, and design Agile or adaptive software.
SOLID stands for:
• S - Single-Responsibility Principle
• O - Open-Closed Principle
• L - Liskov Substitution Principle
• I - Interface Segregation Principle
• D - Dependency Inversion Principle
Single-Responsibility Principle: A class should have only one cause to change, which means it should only have one task.
Here I have created different classes(Addition, Subtraction, Multiplication, Division) which have one job to do.
Open-Closed Principle: Objects or entities should be open for extension but closed for modification.
Liskov Substitution Principle: Let q(x) be a property provable about objects of x of type T. Then q(y) should be provable for objects y of type S where S is a subtype of T.
This means that every subclass or derived class should be substitutable for their base or parent class.
Interface Segregation Principle: A client should never be forced to implement an interface that it doesn’t use, or clients shouldn’t be forced to depend on methods they do not use.
Dependency Inversion Principle: Entities must depend on abstractions, not on concretions. It states that the high-level module must not depend on the low-level module, but they should depend on abstractions.
Top comments (0)