Solid Principles
By learning object-oriented, you will be familiar with abstraction/interface classes, encapsulation, inheritance and polymorphism concepts. But just knowing these terms is not enough to make a clean code; therefore, SOLID principles have come to help us to have a better mindset to design a flexible system by implementing proper classes and set correct relationships between them.
In the following, a tutorial of the SOLID principles is described.
SOLID is an abbreviation of 5 principles in terms of: Single Responsibility, Open-closed, Liskov Substitution, Interface Segregation, and Dependency Inversion.
Single Responsibility Principle (SRP): Each class must have a single responsibility. This rule will help you to prevent the growth of a class irregularly and have easier and fast access to a specific functionality.
Open-Closed Principle (OCP): Classes must be opened to extend but closed for modifications. OCP will help you to better manage different or new conditions.
Recommended by LinkedIn
Liskov Substitution Principle (LSP): If you can substitute the base class by the derived class easily without any crash, then you follow this principle. By this subject, a derived class must have the same behavior as its super-class.
Interface Segregation Principle (ISP): It doesn’t seem nice to have an Interface which forces its sub-classes to implement all functions, even unnecessary ones for a specific subclass; So why don’t break that interface to multi ones depends on functionalities. Yes, it’s the purpose of ISP to prevent unwanted developments.
Dependency Inversion Principle (DIP): By this rule, you can get rid of an object dependency and its effect by functionality or structural changes. By DIP, both high-level and low-level classes will depend on an intermediate abstract/interface class which is not depend on the details.
To better understand by simple and understandable example, I want to introduce the following link, but before going to that link remember that using these principles completely depends on your project status, particularly its size, future expansion, etc. Don't be worried if at first you find SOLID a little laborious to implement, when you want to make changes in your project or maintain it you will recognize its usefulness. Let's go to the lovely practice in the link below to better determine the SOLID.
Learn SOLID Principles with CLEAN CODE Examples By @Amigoscode