How are you dealing with multi-level dependencies in your projects? For example, if I have code with tightly coupled function calls like this:
func A() {
func B() {
func C() {
func D() {
//body here
}
}
}
}
As far as I am aware, one way to decouple is inject dependencies to each function but the function argument lists grows if adding deeper levels, you have to refactor other functions if you decide to have more levels (e.g. level E), etc.
func A(b BInterface, c Cinterface, d Dinterface)
func B(c Cinterface, d Dinterface)
func C(d Dinterface)
Or do you stop at some point, say func C, and start with fresh injection from that point?
Note: I initially posted the question here: https://www.reddit.com/r/golang/comments/ftk03i/how_do_you_manage_multilevel_dependency_injection/
Aucun commentaire:
Enregistrer un commentaire