Get the latest tech news
Dependency injection frameworks add confusion
When working with Go in an industrial context, I feel like dependency injection (DI) often gets a bad rep because of DI frameworks. But DI as a technique is quite useful. It just tends to get explained with too many OO jargons and triggers PTSD among those who came to Go to escape GoF theology. Dependency Injection is a 25-dollar term for a 5-cent concept. — James Shore DI basically means passing values into a constructor instead of creating them inside it. That’s really it. Observe:
Provide takes a function, uses reflection to inspect its parameters and return type, and adds it as a node in an internal dependency graph. While DI frameworks tend to use vocabularies like provider or container to give you an essense of familiarity, they still reinvent the API surface every time. So the promise of “just register your providers and forget about wiring” ends up trading clear, compile-time control for either reflection or hidden generator logic—and yet another abstraction layer you have to debug.
Or read this on Hacker News