S.O.L.I.D Principles of Object Oriented Design


The S.O.L.I.D principles are the basis of a clean system design. It is a summary of the 5 Principles of Object Orientation, published in 2000 by Robert C. Martin created a series of integrated software design principles to master the solid memoir alphabet. These are the rules and best practices to follow when designing software to make software design more understandable, adaptable and maintainable.

The following article explains the S O L I D principles at the initial level where the reader should have a basic idea.

What are the five principles?

01)Single Responsibility
03)Liskov Substitution
04)Interface Segregation
05)Dependency Inversion

01)Single Responsibility principle

Single-responsibility Principle (S.R.P) states:

“A class should have one and only one reason to change, meaning that a class should have only one job.”

This principle states that a class should have a single duty, that is, it should tackle a single problem. Class changes can only be made to changes in a specific area of ​​the software specification. This ensures that there is only one reason to change the class and this is one of the basic principles used by many developers to build robust and maintainable software. You can apply it not only to classes but also to software components and micro services.

02)Open-close Principle

Open-close Principle (S.R.P) states:

“Objects or entities should be open for extension, but closed for modification”

According to the Open-close Principle, it means that every subclass or derivative class must replace their primary or parent class.

Simply put, if something tests and works for you, do not change it. You run the risk of introducing new bugs into your program. Instead, you can extend that class to add new features rather than change it. It tells you to write your own code so that you can add a new functionality without changing the existing code.

03)Liskov Substitution Principle

Liskov Principle (S.R.P) states:

“Every subclass/derived class should be able to substitute their parent/base class”

The Liskov principle is named after Barbara Liskov, who introduced the concept in 1987 in her keynote address on ‘Data Summary’. Liskov.

According to this principle In the development of practical software. The principle defines that objects of a superclass can be replaced with objects of its subclass without violating the application. This requires your subclass objects to carry on like your super class objects.

so that subclass should not have unimplemented functions. after the implemented superclass function, child class should not give different meaning to the functions exist in the base class after overriding them.

04)Interface Segregation principle

Interface Segregation Principle (S.R.P) states:

“In software engineering we try to find a technical solution for a business problem.”

The principle of interface separation during Xerox’s consulting to help build software for their new printing systems He defined it as:

This principle states that most client-specific interfaces are better than one common purpose interface. In other words, you should not be forced to activate interfaces that do not use classes. An extension of the single warranty principle, it aims to divide the software into several specific sections rather than having a common purpose interface.

05)Dependency Inversion principle

Dependency Inversion Principle (S.R.P) states:

“Higher level modules should not depend on lower level modules, but they should depend on abstractions”

According to this principle, classes should rely on abstractions, not concretions. This essentially means that the upper classes with more complex logic and functions should have no effect on the lower classes based on the interface instead.

An in-depth understanding of the SOLID principles and application will not only help you to easily modify, test and recreate code, but will also significantly improve your programming skills.

3rd year Software Engineering Undergraduate