Replies: 1 comment 1 reply
-
|
I think it depends on your relationship with dependency injection as a pattern. Personally, I use it extensively because it's a simple yet powerful pattern that enables great flexibility, so I tend to create many small classes to properly separate concerns. As your application grows, you end up with more classes to instantiate and a deeper dependency tree. The problem is that when you want specific lifetimes per instance (singleton, scoped, transient) or need to swap implementations based on context, the code managing your instantiations can quickly become unwieldy. In particular, scoped lifetimes and pull-based instantiation are extremely difficult to implement correctly without a framework. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I do understand the motivation around using type annotations to reduce wiring friction and improve consistency. That said, in many cases explicit object construction (for example at the application boundary or in main()) seems to require roughly the same amount of code, while remaining more explicit and easier to reason about.
What kind of problems does python-injection solve that are difficult or impractical to address with straightforward, manual dependency wiring?
Beta Was this translation helpful? Give feedback.
All reactions