January 27, 2014

Interface Segregation Principle

Definition: Many client specific interfaces are better than one general purpose interface.

This principle is fairly straight forward in that it is really just saying keep your interfaces to a specific role, keep them small and concise.

Reason:

This enables code concrete classes to not have to implement every single method regardless of whether they need them or not. When injecting classes into other classes using their interface, smaller interfaces can ensure only the methods that are required are initialised, thus removing code bloating.

It also makes the code much easier to read and to test. Readability and testability are almost as important as working code, as without them the code very quickly become difficult to change and easy to break.

Simon Powers
Simon Powers is an Agile Coach specialising in large scale transformations and agile adoption. He has a background in very large enterprise architecture which has led on to organisational design and agile process refinement. Simon is the founder of Adventures with Agile.