dimanche 31 décembre 2017

Implementing multiple interfaces in a class

I have two interface, interface i1 and interface i2. Both of them have different methods. class c1 is extending interface i1 and interface i2.
I am using dependency injection and want to inject the c1 dependency. Also as a good programming practice we should also code to interface. But if i declare a reference variable using i1 then i cant use i2 methods and vice versa.

Also i want that i1 and i2 to be separate interfaces because i1 is being implemented by other classes as well and those classes don't need i2 methods.

What is the best way to solve this problem?

Aucun commentaire:

Enregistrer un commentaire