News for hackers. Stuff that matters.
Re:Clear is better than clever by vkou on Tuesday July 09, 2019 @01:36PM (#20394450)
1. The interface may not be referenced within the particular scope of an injector. Scopes (and the modules that make up an injector) are determined at run-time, so the compiler has no idea whether or not the injector that generates ParentWidget needs FooModule, or not. As long as an object sharing an interface with something that FooModule produces is injected anywhere else in your application, for any reason, you can't statically figure out that you should remove it from the injector that creates ParentWidget.

2. The interface is referenced, the implementations might not even be bound to it, depending on run-time conditions.

Even trivially scoped dependency injection is a fantastic way to make it impossible for your compiler, and very hard for a human, to reason about your dependencies.

There are no comments on this comment yet.