DEV Community

Discussion on: Explain dependency injection like I'm five

Collapse
 
greglockwood profile image
Greg Lockwood

"Dependency Injection" is a fancy way of saying that you have to ask someone else, like Mummy or Daddy, to give you anything you want to play with. You can't make the toy yourself, you need Mummy and Daddy to get it for you.

Sometimes, you don't know what toy you are going to get, like on your birthday, but all you need to know is that it will be a fun toy you can play with when you open the present.

Collapse
 
ben profile image
Ben Halpern

And this really helps mummy and daddy because you're not very good at cleaning or maintaining or watching over your toys. They'd rather not bother you with that stuff. Your "job" is to make use of the toys and have fun, not to build and take care of them.

If parents made their kids learn to create and clean their own toys, it might be possible to teach everyone to do this, but it would be easy to mess up, and they'd have a hard time being sure they got it right.