Dependency Injection

This week, Michael Ludwig and I had a paper published that we’ve been working on for quite some time. ‘Dependency Injection with Static Analysis and Context-Aware Policy’, describing our Grapht dependency injector, has been published in the Journal of Object Technology.

We wrote Grapht to support algorithm configuration in LensKit, our open-source recommender systems toolkit. We didn’t want to write a new dependency injection framework; initially, we built LensKit on top of Guice, and then migrated to PicoContainer when Guice wasn’t a good fit for our needs. But PicoContainer also made it difficult to implement the kind of configuration support we wanted to provide, so we finally broke down and wrote our own.

Grapht provides two major advantages over existing injectors:

As we were working on the design of Grapht on the GroupLens whiteboard, we frequently found ourselves describing its behavior in terms of graph operations. This lead us to the core of our paper: a mathematical formalization of the problem of dependency injection, and graph-based algorithms for constructing solutions to dependency injection problems. Using this formalization, we prove that our context-sensitive policy captures all configurations that are expressible using qualifiers in tools such as Google Guice, making it strictly more expressive.

The paper has all of the details, of course.

This is a bit of an odd paper for us. Besides being in a field that we generally don’t publish in, it is a (successful!) case of turning a yak shave into published research output. I am quite pleased with that outcome.