SOLID Design Principles in Ruby



Michael Feathers and Bob Martin introduced the definition of SOLID principles for object-oriented design.

The term “solid principle” refers to a collection of five fundamental principles that help developers to create flexible solutions, identify software bugs, and refactor their code to avoid problems. And in order to write efficient, adaptable, and clear code, this approach must be followed.

Importance of solid principles

it’s utilised to prevent bad software designs. It’s a coding standard that enhances code’s extensibility, logic, and readability. Design the software in such a manner that the code is reusable and flexible.

Additionally, helps to dividing the code which makes modifications less painful

Why do we need it to maintain that in our application?

A minor modifications can appear as a bug due to poor software designs

To maintain code’s readability, re-usability (means capable of being used again or repeatedly), logic, and extensibility (means meant to allow the inclusion of additional features) for that we applied the SOLID principle.

Suppose we have new functionality to implement so at that time we modify into current code which is tested and deployed over production. There might be a change that break our functionality of entire class which need to refactoring latter. So, we need to structure it in such a way that not impact on your current code and functionality.

These five principles are part of the SOLID design principle:

  • Single Responsibility Principle
  • Open/Closed Principle
  • Liskov Substitution Principle
  • Interface Segregation Principle
  • Dependency Inversion Principle



Previous Post Next Post