Question
Asked 29 April 2015

Do you know any papers on verification of dependency injection modules/IOC containers?

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<:D) and completeness (for all D: exists binding T). Unfortunately, the paper does not handle cases such as scoping, multiple modules etc. And even the simple case of new constructor call as shown in the example is not handled.
[HH13] Hudli, Shrinidhi R. ; Hudli, Raghu V.: A Verification Strategy for Dependency Injection. DOI 10.7763/LNSE.2013.V1.16. In: Lecture Notes on Software Engineering 1 (2013), Nr. 1, S. 71–74

All Answers (3)

  1. please follow these linkshttp://www.ijeit.com/Vol%204/Issue%207/IJEIT1412201501_20.pdf
  2. http://journals.bg.agh.edu.pl/COMPUTER/2013.14.4/csci.2013.14.4.577.pdf
2 Recommendations
Dumitru Ciorba
Technical University of Moldova
The „Scoping” is an important part of any DI-based framework. Scope is about managing the state of objects. And no need to explain why the State is important in applications. So every verification method for DI should aim „Scoping”. Maybe in mentioned paper the Scope is some kind of meta-condition?
Anyway, the scoping implies that the bean to be a context-sensitive type. Under these circumstances, I recommend papers like [1]. The paper targets verification of safety properties for functional programs. However, this paper can be useful to understand how to define a good verification strategy using a compositional technique. In the context of this approach, to handle cases such as scoping, many modules, etc, You should focus on the dependent types (with refinements). Good injections! :)
[1] He Zhu, Suresh Jagannathan, Compositional and Lightweight Dependent Type Inference for ML, Verification, Model Checking, and Abstract Interpretation (14th International Conference, VMCAI 2013, Rome, Italy, January 20-22, 2013. Proceedings), DOI 10.1007/978-3-642-35873-9_19, In: Lecture Notes in Computer Science (2013), pp 295-314
1 Recommendation

Similar questions and discussions

Related Publications

Conference Paper
Full-text available
Program analysis has many applications in software engi- neering and high-performance computation, such as pro- gram understanding, debugging, testing, reverse engineer- ing, and optimization. A ubiquitous compiler infrastruc- ture does not exist; therefore, program analysis is essen- tially reimplemented for each compiler infrastructure. The goal...
Article
Full-text available
In earlier work, we showed that the AspectJ notions of as-pect and class can be unified in a new module construct that we called the classpect, and that this new model is simpler and able to accommodate a broader set of requirements for modular solutions to complex integration problems. We em-bodied our unified model in the Eos language design. The...
Got a technical question?
Get high-quality answers from experts.