Dependency injection (DI) is a great pattern/principle to make code better configurable and testable. 

Using a framework (in Java) such as Guice (or any other JSR 330 implementation), or some other so called "inversion of control (IOC) container", really simplifies using DI. But even the most simple usages are often problematic. E.g. (with an JSR330 annotation with field injection):

class C {  @Inject X x; }

This class must not be created via new in normal client code, because then x cannot be injected. Also, assuming X is an interface, there needs to be a configuration (binding) for X.

I'm wondering if there exist any work on verifying these kind of situations. Are there any IDEs or tools implementing such verification (e.g., creating at least a warning if, given the example above, C is created via new or if no binding for X is detected)? Of course there are many more problems, such as DI cycles etc. 

Do yo know any research addressing these and other issues?

So far, I have only found a single paper [HH13], but this paper only scratches the surface. It defines two constraints which are to be satisfied: Compatibility (a binding T to an injected type D must be a subtype: T

More Jens von Pilgrim's questions See All
Similar questions and discussions