英文原文出处:
http://www.infoworld.com/article/06/03/29/76918_HNrodjohnson_1.html
第一次尝试翻译,多多指教!
在上周的TheServerSide Java大会其间,记者主要就如何简化Java开发、Java的开源以及Spring框架应用、.Net和Java如今的竞争这些问题采访了Rod Johnson。
InfoWorld: 你认为简化java编程的主要障碍在哪?java编程需要多大程度上的简化呢?
Johnson: 在某些方面,我认为JAVA语言本身已经非常漂亮地简化了许多构造,当然是相比于之前使用C++的时期。并且随着Java5的发布,这一简化过程仍然在继续。我们可以看到最具复杂性的方面仍然集中在java服务端编程( the area of server-side ),我认为我们在面向POJO开发方面已经取得长足的进步。很显然,你必须承认这个事实,Java服务端编程相比于原始的J2EE模型已经大大简化。
InfoWorld: 面向切面编程最主要的益处是什么?为什么开发者必须赶上潮流如果他们还未这样做的话?
Johnson: 面向切面编程的主要好处在于它是对面向对象编程的良好补充。面向对象编程推广了一种非常成功的编程范式,重要的是它鼓励我们重用代码(reuse)及减少重复代码。举个例子,你创建了一个account类,savings account,checking account,credit account等子类从此类继承而来。如此以来你拥有了一个完整的类层次来构建你想重用的业务逻辑。可是,仍然有一些问题——我们称之为横切性关注的方面不能得到重用。横切性关注是指一些应用于整个系统的功能性切片,如果它们以传统的OO方式实现,将会侵入到许多的类和方法。(我们不得不在这些类和方法中重复同样的调用,如安全性检查)让我们来举个例子,比如帐户的审核。显然,我们可以在基类account中定义帐户的审核行为。但是我们如何审核所有导致saving account发生变化的方法?为了做到这一点,经典的OO模型没办法避免大量的重复代码。(因为你必须对每个可能导致变化的方法进行审核)你不得不把执行审核的代码分散在各个方法当中。更糟糕的是,当你需要把此审核行为扩展到诸如财产、地址等时,代码的重复问题更加严重。所以AOP提出了切面的概念(相比于方面这个词,切面更形象)。切面是模块化横切性关注的一种方式。在spring framework中,我们的事务管理和安全性检查就是通过AOP提供的,开发者不必被迫明确地使用OOP构造,从本来必须分散的代码进行模块化的方法中得到很大益处。
Johnson: spring framework起源于我的第一本书——出版于02年的《Expert One-on-One J2EE Design and Development》。那本书是关于J2EE所谓的轻量级解决方案。讨论了传统J2EE模型的过度复杂性,公开了30000行代码,提供了一个完整的应用框架来描述我所提倡的简单方式。但是显然,读者们对这些源码很有兴趣,我也被说服,从这些代码上发展成为一个OpenSource项目。开发者们从03年初开始热情的支持此项目。相比于其他框架,spring确实带来了春天:).spring是一个完整的应用框架,源自许多架构层次。常见的如struts,webwork,它们通常是架构的一个层次,即Web framework。spring 与JSF也是不同的。JSF基本上是处理web资源的一种组件模型,而spring的目标是用一种总体结构来把你的应用程序凝聚成整体。所以spring实际上也可以跟JSF整合使用。spring同样提供了一个MVC Web framework,与struts,webwork处于同一层次,但另一方面,spring是一个模型层framework。
InfoWorld: 你曾经形容JCP像一个老化的苏维埃式的计划经济体制。能不能详细谈谈你的观点?
Johnson: I think [it was in] the traditional approach, and in fairness to the JCP, I think this has begun to change now. But the traditional approach involved a committee, which was more often than not dominated by vendors, defining essentially the programming model … The problem with this approach was that it really wasn’t based on either competition or experience. So more often than not, you [found that] really quite complex programming models, such as the original EJB (Enterprise JavaBeans) programming model, were defined by groups of people who did not actually develop applications. So they developed servers. They were highly skilled and highly intelligent people, but that’s not the same thing as being regularly exposed to what people were doing in banks and all the real businesses that actually used this software … So the reason that I referred to the notion of capitalism versus the Soviet system is that the effect of this was that there was something that was mandated. This was the way you were going to do it for the next few years. And it meant that if the approach was not a good approach, it would actually survive for a long time. And it also meant that there wasn’t that much opportunity for the kind of innovation that we see, for example, in business or where you get a lot of competition forcing people to [lift] their [game] and innovate.