Interface Segregation Principle (Php SOLID Design)

Опубликовано: 27 Июль 2026
на канале: Zak H.
5,548
155

Interface segregation is a software design principle and most notable as the I in #SOLID Design Principles.

In object oriented programming, an interface is synonymous to a contract.

When a class implements an interface, it is required to implement all methods defined in that interface.

The interface segregation principle states that:
~~~~~~~~~~~~~~
"No client should not be forced to depend on methods it does not use".
~~~~~~~~~~~~~~

The "client" within this principle is referencing any any class that implements an interface.

The given class (client) "should not be forced to depend on methods it does not use"


This is a reference to interfaces. An interface is "forced" to depend on methods that are within an interface it implements.

When a given interface requires the class to have a method it does not use, then we should follow this SOLID design principle and "segregate" or separate our interface into multiple, smaller interfaces so the class can implement an interface that only demands it has the methods or functions it actually uses.

Clean Code Studio ~ Simplify!
Clean Code Clean Life
https://cleancode.studio

#InterfaceSegregation #php #solidprinciples

https://cleancode.studio/series/solid...