Skip to main content

What does the Interface Segregation Principle mean?

The Interface Segregation Principle (ISP) means that clients should not depend on interfaces they do not use.

In detail:

1. The essence of the principle

An interface should be small and specialized. If an interface forces classes to implement methods the client does not need, it is too "fat" and violates ISP.

2. The problem with "fat" interfaces

When an interface contains many unrelated methods, an implementation is forced to support functionality it does not need. This leads to:

  • unnecessary dependencies,
  • false cohesion,
  • fragile code,
  • frequent changes caused by clients that use other methods.

3. What ISP requires

Split large interfaces into a set of small, logically complete interfaces, each responsible for a single role. A client only depends on the interface it actually needs.

4. Motivation for the principle

When interfaces are too large, any change to one part of the interface forces a change in all implementations, even ones that do not use that method. This breaks stability and increases coupling.

5. Key idea

It is better to have several small interfaces (IPrinter, IScanner) than one large one (IMachine with five methods) that is mandatory for everyone.

Summary: ISP requires creating small, targeted interfaces so that clients depend only on the methods they actually use, which reduces coupling and increases the flexibility of the system.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.