4 ms·
Can you explain how a library for dependency injection could improve a Go standard library like net/http, io, encoding/json, or database/sql?
by echlebek 9y ago
Can you explain how a library for dependency injection could improve a Go standard library like net/http, io, encoding/json, or database/sql?
- JBReefer 9y agoIt wouldn't. It is for when you want to swap out that library, or test business logic using that library beyond simple unit tests. DI is also great for creating modular code you compose, instead of monoliths. It encourages the use of interfaces and information hiding - you should look into it, it's a very powerful technique. Instead of asking how it would improve an arbitrary library, ask yourself "how screwed am I if 100% of the API surface for this library changes tomorrow?" Dependency injection would help you out of that faster that rewriting everything.