浏览 5015 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2004-08-10
Different people has differnent idea. Some people said Ioc is a new thing, some think IOC is old tech. In my opinion, it seems we just get POJO and decoupling. However, we still need to define class relationship in other place such as xml configuration. Is it really good for us? If I can choose, I prefer to chose interface programming. Because I feel interface is more direct and clear. Well, probably, you guys have different opinion. Inversion of Control - Dependency Injection (former type 3); - Constructor Dependency Injection Examples : PicoContainer Spring Framework - Setter Dependency Injection (former type 2); Examples : Spring Framework PicoContainer - Interface Driven Setter Dependency Injection Examples : XWork WebWork 2 - Field Dependency Injection Examples : Plexus (to be confirmed); - Dependency Lookup - Pull approach (registry concept); Examples : EJB that leverages JNDI Servlets that leverage JNDI - Contextualized Dependency Lookup (former type 1); AKA Push approach Examples : Servlets that leverage ServletContext Avalon JContainer's DNA OSGi (to be confirmed); Keel (uses Avalon); 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2004-08-10
bruce 写道 we still need to define class relationship in other place such as xml configuration. Is it really good for us? If I can choose, I prefer to chose interface programming.
我觉得这不是个问题。毕竟,我们终归要在“某个地方”定义这些关系。这“某个地方”,写单元测试的时候往往就是Java代码(注射一堆mock),产品中通常就是XML配置文件。我是觉得这样挺好的,比如说我要把持久化机制从关系数据库换到LDAP,我就改一个DAO bean的配置,不用跑到代码里翻来翻去的。 为什么说xWork是“Interface Driven Setter Dependency Injection”呢?虽然xWork Action都要从Action接口继承下来,但这个接口跟Injection是没什么关系的。 |
|
返回顶楼 | |
发表时间:2004-08-10
其实Ioc,Dependent Injection 都是面向接口的编程,如果没有面向接口编程这些都不复存在了,所以Ioc
与interface programming并不矛盾。 |
|
返回顶楼 | |
发表时间:2005-01-17
gigix 写道 我觉得这不是个问题。毕竟,我们终归要在“某个地方”定义这些关系。这“某个地方”,写单元测试的时候往往就是Java代码(注射一堆mock), 注射一堆mock,注射是什么意思?怎么理解? gigix 写道 产品中通常就是XML配置文件。我是觉得这样挺好的,比如说我要把持久化机制从关系数据库换到LDAP,我就改一个DAO bean的配置,不用跑到代码里翻来翻去的。 除了修改该配置之外,我们还需要提供一套适用LDAP的DAO bean。软件开发还是劳动密集型的产业,增加功能,切换数据库或者其他的持久机制,少不了要开发程序,增加工作量,不是easy不easy,而是很烦很累。当然如果有人做了(比如hibernate之对于不同类型数据库)我们可能拿过来借用,就减少了这部分工作。 gigix 写道 为什么说xWork是“Interface Driven Setter Dependency Injection”呢?虽然xWork Action都要从Action接口继承下来,但这个接口跟Injection是没什么关系的。 还是不能够了解Injection到底怎么解释好呢? 刚看Spring的文档,看提到 IOC和Dependency Injection,martin flower的讨论,链接如下: http://martinfowler.com/articles/injection.html |
|
返回顶楼 | |
发表时间:2005-01-17
胡乱理解,有错请骂
注射mock的意思就是你在做test case的时候,丢个假的实现方式给你要测试的那个家伙。有人把IOC容器比做奶妈,放在这里就是平时是给你的对象喂奶的测试的时候没奶了,为了让测试成功要喂点奶粉冒充,为了测试失败就把奶瓶里罐点二锅头给他喂下去。。。 你说的那个文章看看中文版,谁翻译的,我第一次下一看连接吓一跳。。。绕一圈又回去了 |
|
返回顶楼 | |