tags:

views:

662

answers:

4

The Interface Segregation Principle says that many client specific interfaces are better than one general purpose interface. Why is this important?

+11  A: 

ISP states that:

Clients should not be forced to depend on methods that they do not use.

ISP relates to important characteristics - cohesion and coupling.
Ideally your components must be highly tailored. It improves code robustness and maintainability.

Enforcing ISP gives you following bonuses:

  • High cohesion - better understandability, robustness
  • Low coupling - better maintainability, high resistance to changes

If you want to learn more about software design principles, get a copy of Agile Software Development, Principles, Patterns, and Practices book.

aku
if you're a C# junkie: this book is also available tailored to C#. It's called Agile Principles, Patterns, and Practices in C#.
Erik van Brakel
Erik, I already read it :-)
aku
+1  A: 

It simplifies the interface that any one client will use and removes dependencies that they might otherwise develop on parts of the interface that they don't need.

Bill the Lizard
+1  A: 

There's a nice paper which goes into some depth about this principle here.

Phillip Wells
+1  A: 

One reason is that having many interfaces with a minimal amount of methods for each one makes it easier to implement each interface and to implement them correctly. A large interface can be unruly. Also, using a focused interface in a scenario makes the code more maintanable because you can see which facet of the object is being used (e.g., an IComparable interface lets you know that the object is only being used for comparisons in the given scenario).

Mark Cidade