DEV Community

Discussion on: Who is Uncle Bob?

Collapse
 
bias profile image
Tobias Nickel

I like to ask you something about the mechanics of dependency injection?

in dot.net, you configure what implementation to use and inject in a Startup class. in testing or different environment you can use different implementations of the startup class and thus choose the implementation. this is to have some dependency configuratiob.

in java spring framework there js a dependency injection configuration as xml.

in angular with typescript, there are modules fikes within the folder structure.

an other approach, other then using a framework, is to do dependency injection manually. some code know how to wire this app together. or even dependencies get passed into functions,... basically DI all over the code.

In JS for testing it is also pissible to use modules like rewire, that change the implementation of the require method to provide a mock into the module, sometimes used in testing.

what are your opinions on these mechanics? do you prefer it more abstract in a framework, or more direct with more hand work?