SOLID Introduction

  1. SOLID is a superset of 5 principles. These principles are basically used to design the application which will help to simplify the development and make that maintainable and testable.
  2. The SOLID acronym was first introduced by Michael Feathers.
  3. With the use of SOLID principles, most of the software design problems get solved as these are based on the very basics of the Object-Oriented programming. As everything in the application will be treated as Object, there should some rules to use it.

SOLID Acronym

  • S - Single Responsibility Principle (SRP)
  • O - Open closed Principle (OSP)
  • L - Liskov substitution Principle (LSP)
  • I - Interface Segregation Principle (ISP)
  • D - Dependency Inversion Principle (DIP) – Not Dependency Injection
Now, let’s see each principle in detail including basic understanding and definition.

Single Responsibility Principle

Open/Closed Principle

Liskov Substitution Principle

Interface Segregation Principle

Dependency Inversion Principle

There are some Common Criticisms of SOLID,
  • SOLID Principles Are Vague
  • SOLID Leads to Complex Code
  • SOLID Is Too Idealistic
  • SOLID Is a Marketing Gimmick
Answer to this criticism is SOLID is Principles, not RULES. If you don’t want to implement, don’t do it but then, you will be facing many problems as you grow up with the application. Some are as below.
  1. Singleton
  2. Tight Coupling
  3. Untestability
  4. Premature Optimization
  5. Indescriptive Naming
  6. Duplication
Following the SOLID Principle helps us to:
  1. Achieve a reduction in complexity of code. Sometimes it increases complexity, however, it gives other facilities or advantages in the long run.
  2. Increase readability, extensibility, and maintenance
  3. Reduce error and implement reusability. As reusability is the core of programming we must not duplicate the code while developing.
  4. Achieve better testability. This is the most important part of the application as quality is one of the most serious concerns.
  5. Reduce tight coupling which is most important in big applications
--Happy Coding--