4 ms·
The issue I have with DI frameworks is the annotation scanner scanning all jars in the classloader and annotation magic. It seems that vanilla Guice does not n
by EdSharkey 10y ago
The issue I have with DI frameworks is the annotation scanner scanning all jars in the classloader and annotation magic.
It seems that vanilla Guice does not need to fire up an annotation scanner that hits every jar, so that's good. It's been years for me, but I seem to recall Spring Framework does a brutal amount of jar crawling/annotation scanning by default. Unfortunately, it's very easy to corrupt Guice with annotation scanning - Netflix Governator will introduce a scanner for its magic annotations, for example.
As far as annotation magic is concerned, I think having an agreed-upon convention for DI can really help to keep things manageable and easy while still being able to unit test/inject mocks. For example, my team tries to only inject on constructor args. This makes it a no-nonsense affair to factor out features for a unit under test by passing in mocks for injected dependencies.
Testing complex systems, for me, is the killer app for DI - if I am writing something I need to test, I abhor the new keyword and FactoryFactories in my production code.