What’s the Interface Segregation Principle?

Get a brief introduction to the interface segregation principle.

In object-oriented programming, interfaces are used to define signatures of methods and properties without specifying the exact logic inside of them. Essentially, they act as a contract that a class needs to adhere to. If the class implements any particular interface, it should contain all components defined by the interface as its public members.

The interface segregation principle states that if any particular interface member isn’t intended to be implemented by any of the classes that implement the interface, it shouldn’t be in the interface. It’s closely related to the single responsibility principle by making sure that only the absolutely essential functionality is covered by the interface and the class that implements it.
`

Get hands-on with 1400+ tech skills courses.