Skip to main content
Bumped by Community user
Bumped by Community user

Why do we needseparate interface when implementing interface injection variant of DI?

With interface injection (wikpedia) we have a method to set the dependency on the client as part of an interfase.

public interface ServiceSetter { public void setService(Service service); } 

Why do we need to putseparate interface for the setter method in different interface instead of just having it just in the client class? What's the benefit of having interface?

Why do we need interface injection?

With interface we have a method to set the dependency.

Why do we need to put the setter method in different interface instead of client class? What's the benefit of having interface?

Why do we separate interface when implementing interface injection variant of DI?

With interface injection (wikpedia) we have a method to set the dependency on the client as part of an interfase.

public interface ServiceSetter { public void setService(Service service); } 

Why do we need separate interface for the setter method instead of just having it just in the client class?

Source Link

Why do we need interface injection?

With interface we have a method to set the dependency.

Why do we need to put the setter method in different interface instead of client class? What's the benefit of having interface?