DEV Community

Discussion on: Explain dependency injection like I'm five

Collapse
 
eljayadobe profile image
Eljay-Adobe

Traditional: going to a party, bring your own drinks.

Inversion of control: going to a party, there is an ice chest full of drinks, and there's a guy handing out the drinks from the ice chest. You only get to drink what's been handed to you.

Dependency injection: going to a party, and there's an open bar, the bartender makes your drinks, and servers brings you your drinks. You don't know what you're drinking, but it tastes good.

Dependency injection is a fancy kind of Inversion of Control, but also has a bartender & servers.

Collapse
 
elenadotnet profile image
Elena.NET

awesome!