The Solid principles

The SOLID acronym was introduced by Robert Martin (also known as “Uncle Bob” and represents a list of five guidelines that can enhance the maintainability of the software.

Bad dependency management will make your code rigid, fragile, difficult to reuse. Rigid code is that which is difficult to modify, either to change existing functionality or add new features. Fragile code is susceptible to the introduction of bugs, particularly those that appear in a module when another code is changed.

If you follow SOLID principles, you can produce better and flexible code, more robust and with a higher reusability.

The 5 principles:

1. Single Responsibility Principle (SRP) – each class should have one responsibility and, therefore, only one reason to change.

2. Open / Closed Principle (OCP) – all classes and similar units of source code should be open for extension but close to modification.

3. Liskov Substitution Principle (LSP) – code that uses a base class must be able to substitute a subclass without knowing it.

4. Interface Segregation Principle (ISP) – the client should not be forced to depend upon interfaces that they do not use. Instead, those interfaces should be minimized.

5. Dependency Inversion Principle (DIP) – high level modules should depend upon low level modules and that abstractions should not depend upon details.