Search code examples
solid-principlessingle-responsibility-principleinterface-segregation-principle

Interface segregation principle and single responsibility principle


I have an interface with 9 methods each doing something different but in one context. That is, when I use dependency injection on this interface, all 9 methods are used in one specific scope. Should I do 9 different interfaces for all methods and 9 classes to implement these interfaces if I always use all 9 methods after creating an instance?


Solution

  • If you would use all or most of these nine methods in every use case, then it is clear that you do not need interface segregation.

    However, the reason you are even asking this is probably that having nine methods appear too much. This may be the case and it sounds like perhaps you need some refactoring, but no one can tell you that without studying your code.