Closed lucdoe closed 1 month ago
I found this comment in the wire docs:
Should I use Wire for small applications? Probably not. Wire is designed to automate more intricate setup code found in larger applications. For small applications, hand-wiring dependencies is simpler.
I also want to improve with DIP, so I will probably go with the approach of doing it myself.
Decision: handwire the dependencies.
An important point of injecting dependencies is to avoid injecting implementations (structs), you should inject abstractions (interfaces). It’s the letter D of S.O.L.I.D: Dependency Inversion Principle. It allows you to switch easily the implementation of some dependency and, you could change the real implementation for a mock implementation. It's fundamental for unit testing.
See: https://medium.com/avenue-tech/dependency-injection-in-go-35293ef7b6
My idea was to think about a dependency injection straight from the start. I stumbled upon Wire and considered using that. This article explains why that might be a good idea.