SOLID Principles

Abhinay Gupta
5 min readJun 4, 2023


Solid Principles

Why Solid principles?

▪If Android developers design and implement their codes without using structured design principles such as SOLID principles, they will create long-lasting problems, and probability of success for an application will be decreased in future.

▪ Using SOLID principles in Android development could be helpful and effective to follow clean code principles.

▪ If developers design and implement their codes without using structured design principles such as SOLID principles, they will create long-lasting problems for other developers that will want to work on the project in future. So, the probability of success for this type of software will be diminished in future. This issues are commonly referred to Software Rot. (Software Rot or Code Rot or Software
is either a slow deterioration of software quality over time or its decreasing responsiveness, which will eventually lead to software becoming faulty, unusable, and in need of upgrade. )

Single Responsibility Principle (SRP)

  • A class should have only a single responsibility.
  • ▪ Each class or module should be responsible for one part of the functionality provided by the app. So when it handles one thing, there should be only one main reason to change it. If your class or module does more than one thing, then you should split the functionalities in separate ones.
Before Using SRP
riAfter Using SRP


Software entities should be open for extension, but closed for modification

This principle states that when you write all the software parts like classes, modules, and functions, you should make them open for extension but closed for any modification.

Before Using Open/Closed principle
After Using Open/Closed principle

Liskov’s Substitution Principle

Objects in a program should be replaceable with instances of their subtypes without altering the correctness of that program.

This principle is named after Barbara Liskov — an accomplished computer scientist. The general idea of this principle is that objects should be replaceable by instances of their subtypes without changing the behavior of the program.

Before Using Liskov’s Substitution Principle
After Using Liskov’s Substitution Principle

Interface Segregation Principle

Segregation means keeping things separated, and the Interface Segregation Principle is about separating the interfaces.

The principle states that many client-specific interfaces are better than one general- purpose interface. Clients should not be forced
to implement a function they do no need.


Dependency Inversion Principle

The Dependency Inversion principle states that our classes should depend upon interfaces or abstract classes instead of concrete classes and functions.

We want our classes to be open to extension, so we have reorganized our dependencies to depend on interfaces instead of concrete classes.

The above lines simply state that if a high module or class will be dependent more on low-level modules or class then y\our code would have tight coupling and if we try to make a change in one class it can break another class which is risky at the production level.

So always try to make classes loosely coupled as much as we can and we can achieve this through abstraction. The main motive of this principle is decoupling the dependencies so if class A changes the class B doesn’t need to care or know about the changes.


We can consider the real-life example of a TV remote battery.Our remote needs a battery but it’s not dependent on the battery brand. We can use any XYZ brand that we want and it will work. So we can say that the TV remote is loosely coupled with the brand name. Dependency Inversion makes our code more reusable.


https: //www. freecodecamp. org/news/kriptofolio-app- series-part-1/

https: //medium. com/the-android-café/solid-principles- the-kotlin-way-ff717c0d60da

https: //medium. com/kayvan-kaseb/the-solid-principles- for-android-developers-75fd4ca3ef84

https: //proandroiddev. com/s-o-l-i-d-principles- 60e0f91afa6

https: //proandroiddev. com/exploring -s-o-l-i-d-principle- in-android-a90947f57cf0

https: //medium. com/codex/solid -principles-in-android- cdc226605111

https: //medium. com/android -news/android- development-the-solid-principles-3b5779b105d2

https: //medium. com/kayvan-kaseb/the-solid-principles- for-android-developers-75fd4ca3ef84

https: //www. baeldung. com/solid -principles

https: //stackify. com/interface-segregation-principle/