Sitemap

Member-only story

What is the Interface Segregation Principle? (With Code Example) — SOLID

5 min readApr 17, 2025

This principle tells us that instead of putting all responsibilities into one big interface, it’s better to make smaller interfaces that are specific to what they do.

We should use many smaller interfaces that are broken down based on how they are used, instead of one big interface. This means each different job should have its own interface. This way, someone using the interface only needs to worry about the things they need. If we have just one interface for many purposes, it means we are adding more methods or features than needed, and this goes against the IS principle.

Objects should never be forced to implement interfaces that have properties or methods they don’t need.

As you can see, the single responsibility principle and the interface segregation principle are quite similar and aim for the same thing. The only difference is that interface segregation deals with interfaces, while single responsibility deals with classes.

If we add a method to an interface that doesn’t follow the IS principle, or if we change a method in it, we will need to change all the classes that use (implement) that interface. When writing an interface, it’s always important to separate different responsibilities or groups of actions into different interfaces.

--

--

Gökhan Ayrancıoğlu
Gökhan Ayrancıoğlu

Written by Gökhan Ayrancıoğlu

Software Engineer & Team Lead @Colendi • #Java • #Spring Boot • #Kotlin • #Microservices • https://gokhana.dev

No responses yet