如何向一个 5 岁的孩子解释依赖注入? [英] How to explain dependency injection to a 5-year-old?

查看:22
本文介绍了如何向一个 5 岁的孩子解释依赖注入?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是解释依赖注入的好方法?

我在 Google 上找到了几个教程,但没有一个会假设读者只是 Java 初学者.你会如何向新手解释这一点?

I found several tutorials on Google, but none of them that would assume the reader is just a Java beginner. How would you explain this to a novice?

推荐答案

我给你五岁孩子的依赖注入.

I give you dependency injection for five-year-olds.

当您自己从冰箱中取出东西时,可能会引起问题.你可能把门开着,你可能会得到一些妈妈或爸爸不希望你拥有的东西.您甚至可能正在寻找我们甚至没有或已过期的东西.

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.

这篇关于如何向一个 5 岁的孩子解释依赖注入?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆