Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
A toy needs batteries. therefore, you must 'inject' the battery into the toy.
Something like that? -
mhall2748yWell ... you could tell them to make a mud pie.
But to do that they have to go out dig up a pile of mud/clay *before* they can make it.
Then you can tell them to make *another* mud pie, but this time you give them the mud to make it with.
Wait ... are kids even allowed to play with mud any more?
You might have to pick a different example ... -
chrizzle7268yDave has a computer. It is very good and being a computer.
Dave also has a printer, it is very good at printing pictures.
Dave's computer knows how to say "print this image please", but it does not know how to print one itself because it is busy being a good computer. It depends on a printer for that.
Dave's printer understands what "print this image please" means and how to do it because it is busy being a good printer.
Disaster! One day, Dave's printer stops working :(
Dave is worried, will he have to fix his computer or buy a new one? Of course not, because his computer doesn't know how to print, he doesn't have to!
Because all printers understand "print this image please", Dave simply buys a new printer for his computer to depend on.
"Hooray for separation of concern" says Dave. -
xuilo06yThe dependency injection is about dividing holding from accessing.
You can say to 5 years old child that by watching video on YouTube it does not mean you have it on your laptop hard drive as file because by accessing video file from the internet it does not mean you actually download it.
Related Rants
-
Mindstormer61911Jesus Christ. Dagger2's documentation has got to be the most convoluted shit I have ever laid my eyes on. The...
-
progresshuh19Dependency Injection Frameworks are absolute shit. I have yet to encounter one that doesn't make code take ho...
-
k0pernikus1As I was refactoring a class in a TypeScript project, I changed calls from `this.config` to `this.getConfig()`...
How could you explain the purpose of dependency injection to 5 years old child?
undefined
dependency injection