How does the SOLID “Interface Segregation Principle” differ from “Single Responsibility Principle”?
The Wikipedia entry for SOLID says that
ISP splits interfaces which are very large into smaller and more specific ones so that clients will only have to know about the methods that are of interest to them
However, to me that sounds like just applying the SRP to interfaces as well as classes. After all, if an interface is only responsible for just one conceptual thing, than you wouldn’t be able to break it down further.
Am I missing something, or is ISP sort of redundant with SRP? If not, then what does ISP imply that SRP does not?
SRP tells us that you should only have a single responsibility in a module.
ISP tells us that you should not be forced to be confronted with more than you actually need. If you want to use a
print()method from interfaceI, you shouldn’t have to instantiate aSwimmingPoolor aDriveThruclass for that.More concretely, and going straight to the point, they are different views on the same idea — SRP is more focused on the designer-side point-of-view, while ISP is more focused on the client-side point-of-view. So you’re basically right.
It all came from
so
@ http://en.wikipedia.org/wiki/Interface_segregation_principle#Origin