DEV Community

Discussion on: Explain Dependency Injection (DI) like I am five.

Collapse
 
gjrdiesel profile image
Justin

Say you’re hungry. With dependency injection, you can just tell mom you’re hungry and she’ll feed you something that matches the food interface.

Without DI, you decide and gather the bread, ketchup, mustard and a hotdog put it all in a bin and bring it to mom and she makes you a hot dog.

Collapse
 
chhuang215 profile image
Chih-Hsuan Huang

Isn't this what IOC is?

Collapse
 
tam360 profile image
Mirza

I think DI uses the idea of IoC behind the scenes

Collapse
 
tam360 profile image
Mirza

So it's kind of like high level abstraction which hides all the complexities and give you what you really need. Interesting.