By bloid
via googletesting.blogspot.com
Published: Aug 05 2008 / 02:44
So you discovered dependency injection and GUICE and you are happily refactoring and writing new tests for you code until you come across this circular reference.
Comments
Jakob Jenkov replied ago:
Circular dependencies can be setup cleanly in Butterfly DI Container like this:
beanA = com.myapp.A(b = * com.myapp.B());
config{ $b.setA($beanA); }
when you obtain A it will contain a B, and B will have it's A set on it using setA();
... or you could just have the factory call a static method that wires up A and B correctly for you. No proxies like Guice does... and far better performance. This circular dependency check is according to Bob Lee one of the performance "killers" of Guice, and probably the main reason why Butterfly is so much faster than Guice.
jw8369 replied ago:
But with Butterfly, B needs to be mutable.,
Voters For This Link (6)
Voters Against This Link (0)