关于IoC的绝妙比喻

news/2024/5/18 12:57:28 标签: ioc, bbs, dao

发信人: dev (无间~一念天堂,一念地狱), 信区: J2EE
标  题: 关于IoC的绝妙比喻(zz)
发信站: BBS 水木清华站 (Mon Jul 19 08:30:00 2004), 站内

A girl wants to kiss a boy.
The girl's name is Daisy Anne O'Leary (DAO).  She has red hair.
The boy's name Ed (it's my example), he has a swimming pool (filled with database connections).
 
In our current approach (Service Locator/Singleton)..., Daisy has to go to an central known place (Dating Service), 

and ask it for Ed.  Daisy has to have built-

in knowledge about about the dating service, she has to know how to fill out the right forms to get someone like Ed.

  If she moves to a different dating service, she might have to go through a totally different process to get hooked up 

with Ed.


In the Inversion of Control / Dependency Injection approach..., Daisy knows she has needs...  Ed knows he has what 

it takes to fill those needs.  Daisy and Ed both live in the same neighborhood and have a mutual friend.  That friend 

takes Ed and introduces him to Daisy, the magic happens.  Smart-

mouthed red headed kids are soon tearing up the neighborhood.

--

※ 来源:·BBS 水木清华站 smth.org·[FROM: 221.218.21.*]


http://www.niftyadmin.cn/n/1373647.html

相关文章

海南2019年创新五项制度推进自贸区建设

海南省长沈晓明作《政府工作报告》 骆云飞 摄 海南省长沈晓明作《政府工作报告》 骆云飞 摄 中新网海口1月27日电 (记者 王子谦)海南省六届人大二次会议27日在海口开幕,海南省长沈晓明在作《政府工作报告》时说,2019年海南将从五方面进行制度创新&#x…

configfs-用户空间控制的内核对象配置

1. 什么是configfs? configfs 是一个基于内存的文件系统,它提供了与sysfs相反的功能。sysfs 是一个基于文件系统的内核对象视图,而configfs 是一个基于文件系统的内核对象管理器(或称为config_items)。 在 sysfs 中&#xff0c…

庚子赔款的最终实际情况

发信人: yss2000 (不偷不搶不後勤), 信区: TsinghuaCent 标 题: 庚子赔款的最终实际情况: 发信站: BBS 水木清华站 (Tue Jul 20 00:05:07 2004), 站内【 以下文字转载自 History 讨论区 】 发信人: zanzhang (yun), 信区: History 标 题: 庚子赔款的最终实际情况&…

configfs_sample.c 理解

1. 编译运行 代码从如下链接获得: https://github.com/torvalds/linux/blob/master/samples/configfs/configfs_sample.c 编写 Makefile 文件: obj-m configfs_sample.o all:make -C /lib/modules/$(shell uname -r)/build M$(PWD) modules clean:mak…

最重要的 10 几个 J2EE 最佳实践

发信人: was (银杏叶◇The Day of Days), 信区: J2EE 标 题: 最重要的 10 几个 J2EE 最佳实践 (IBM dW) 发信站: BBS 水木清华站 (Tue Jul 13 20:52:45 2004), 站内IBM WebSphere 开发者技术期刊: 最重要的 10 几个 J2EE 最佳实践级别: 初级Kyle Brown, 高级技术成员, IBM Sof…

智库大会 | 高端对话:智能科技推动管理学变革 ...

随着生产力的加速进化,人类社会的组织形态也在同步进化。过去一百年来大行其道的是刚性科层组织模式,现在一种全新的分工/协同模式,一种能够自我组织、自我适应的组织形态——“液态组织”出现。在数字化和智能化的技术条件下,这种…

块设备驱动、bio理解

别人写过的内容,我就不写了。贴一下大佬的博客,写的非常好: 块设备驱动实战基础篇一 (170行代码构建一个逻辑块设备驱动) 块设备驱动实战基础篇二 (继续完善170行过滤驱动代码至200行) 块设备…

爱情发展流程图

screen.width-333)this.widthscreen.width-333" border0>