Simple way to understand or explain dependency injection

Recently, I have been trying to learn about anjular.js and mean while i am reading this tutorial (!/lessons/a-simple-app) i saw a great answer about describing what is dependency injection. This was the great and simple answer i have ever read. Some one has asked

How to explain dependency injection to a 5-year old?

and simple answer given by John Munsch was

When you go and get things out of the refrigerator for yourself, you can cause problems. You might leave the door open, you might get something Mommy or Daddy doesn’t want you to have. You might even be looking for something we don’t even have or which has expired.

What you should be doing is stating a need, “I need something to drink with lunch,” and then we will make sure you have something when you sit down to eat.

Wow that is great answer isn’t it?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.