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:
Is it though? IMO the explicit code is shorter, cleaner and easier to read. The DI framework code I don’t know what it is doing and looks like more lines of code.
Is it though? IMO the explicit code is shorter, cleaner and easier to read. The DI framework code I don’t know what it is doing and looks like more lines of code.