Skip to content
IT glossary
ProgrammingUpdated December 3, 2026

Interface segregation principle

Принцип разделения интерфейсов

Code should depend only on the operations it needs. When different callers use different capabilities of the same component, give them interfaces that match what they actually do.

Also known as: ISP

What the principle means

The interface segregation principle (ISP) is the I in SOLID. It says that clients should not be forced to depend on methods they do not use. Here, a client is a piece of code that calls another component. A receipt printer needs to print; it should not require a contract that also promises scanning just because some office devices do both.

Design around the caller

Start by looking at what callers actually do, not by listing everything a class can do. Put operations that belong to the same role in one interface, then declare that interface as the type of the dependency. The distinction matters: defining a Printer interface will not help if the checkout code still accepts a MultifunctionDevice.

The interfaces do not have to mirror the implementation. A single driver can implement both Printer and Scanner and share the same connection to the device. The checkout code can use that driver through Printer without knowing anything about scanning.

Example in Java

Suppose a checkout service only prints receipts, but its original OfficeDevice dependency required both printing and scanning. A print-only device would have to supply a scan method it cannot meaningfully implement. Separate the two capabilities instead:

interface Printer {
    void print(String text);
}

interface Scanner {
    byte[] scan();
}

class Checkout {
    private final Printer printer;

    Checkout(Printer printer) {
        this.printer = printer;
    }

    void issueReceipt(String text) {
        printer.print(text);
    }
}

Checkout now accepts either a receipt printer or a multifunction device that implements Printer. A test double can record the text it was asked to print without providing a dummy scan method. If the scanning contract later adds a resolution setting, neither checkout nor its print-only test double needs to change for that reason.

Where it helps and where to stop

Look for this problem in service dependencies, repositories, and plug-in contracts. A common clue is an implementation that does nothing or throws UnsupportedOperationException solely to satisfy a method its clients never need. Another clue is a test that has to stub unrelated operations just to construct the component under test.

ISP is not a rule about method count. Several operations can belong together if they form a coherent capability. Splitting every method into its own interface can leave callers juggling types without removing any meaningful dependency. Split where callers have distinct needs, not merely where the method list looks long.

How it comes up in interviews

An interviewer may give you a large interface and ask how you would refactor it. Identify the callers first, show the contract each one needs, and explain what changes no longer affect each caller. If asked to distinguish ISP from dependency inversion, focus on the questions they answer: dependency inversion concerns the direction of dependencies and the use of abstractions; interface segregation concerns what a caller's contract should expose.