设计模式 – 如何解释依赖注入到5岁?

什么是解释 dependency injection的好方法

我在Google上发现了几个教程,但没有人会认为读者只是一个Java初学者。你会怎么解释这个新手?

我给你五岁的依赖注入。

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.

相关文章

迭代器模式(Iterator)迭代器模式(Iterator)[Cursor]意图...
高性能IO模型浅析服务器端编程经常需要构造高性能的IO模型,...
策略模式(Strategy)策略模式(Strategy)[Policy]意图:定...
访问者模式(Visitor)访问者模式(Visitor)意图:表示一个...
命令模式(Command)命令模式(Command)[Action/Transactio...
生成器模式(Builder)生成器模式(Builder)意图:将一个对...