DEV Community

Discussion on: Dependency injection in functional programming

 
koresar profile image
Vasyl Boroviak

The only difference I see is that with DI the replaced value can be data.

Sorry. I still believe DI and ability to mock is the same concept - ability to replace a thing down the call chain.

Thread Thread
 
psfeng profile image
Pin-Sho Feng

Dependency injection is a concept and the ability to mock is a consequence of this concept, but it's by no means the only benefit.

You could, for example, use some class across different sections of an app but have it behave differently depending on the section. Using the dependency injector you can configure the different instances of the class that will be used in each section.