Seedwork 源框架
Martin Fowler 马丁·福勒
11 September 2003 2003-9-11
In the very earliest days of Object-Orientation, the OO advocates like me put a lot of attention into arguing in favor of reuse. Early on we talked about reusing of classes. Then we discovered that reusing individual classes, while it worked in some cases, didn't work so well elsewhere. So we got into reusable frameworks, which got us part-built applications of functionality.
在面向对象的最早期,像我这样的面向对象支持者,把大量的注意力放到了讨论复用的好处上。早期我们谈到了复用的类。然而我们发现,复用一个独立的类,在某些情况下很好用,但是在某些情况下却不行。所以我们就考虑可复用的框架,它能够让我们部分构建应用程序的功能。
On the technical side, this kind of reuse has been a success - just look at the large libraries available with such environments as Java and .NET (and not just OO - as CPAN demonstrates). But particularly on the business side, such reuse hasn't been so quick to appear. And of the technical side many people feel that many of the frameworks they deal with are too complex for their purpose, and this complexity gets in the way of making these things useful.
在技术方面,这种复用已经很成功了——就像Java、.Net环境中的类库。(当然不仅仅是面向对象领域-比如CPAN(Comprehensive Perl Archive Network- Perl程序库)演示)。但是在业务方面,这种复用就没有这么快的出现。很多搞技术的人觉得从他们的使用目的来看,大多数框架对他们来说太过复杂。但是他们还是会以这种复杂的方式应用于平时的开发。
A recent weblog by Michael Feathers dug into this question, the resulting discussion came up with an alternative notion - the seedwork. A framework is supposed to be a part-baked application that you extend in controlled ways to provide what you need. A seedwork is some minimal functionality that you modify however you like to get what you need. Of course this means that there's no way for you to get common updates to the seedwork, once you grow it you own it. This is the kind of copy and paste reuse that many people, including me, deride.
最近迈克尔.菲瑟斯在他的博客中提出这个问题,讨论过程中,提出了一个替代的概念- seedwork。框架我们可以认为部分拷贝到我们的应用程序中,根据我们的需求在一些限制下进行扩展。seedwork是一些最小的功能,并且你可以根据你的需求进行任意的修改。当然,这就意味着,你不可能有一个通用的方法来修改seedwork,一旦你扩展了它,那它就只属于你的系统。这是一种被很多人鄙视的复制和粘贴的复用方式,同样我也鄙视使用这种方式。
Maybe I shouldn't be so scornful. Frameworks and libraries work very well when they are well-seasoned. But getting a good framework is very hard. Seedworks are not as useful as a good framework, but are easier to create and use. The point is not whether they are ideal, but just whether they are useful.
也许我不应该这样。一些经过长时间实际应用的框架和库,能够很好地应用于我们的开发工作。但是往往很难找到一个好的框架。Seed Works可能不像一个好的框架那么好用,但它更容易创建和使用。问题的关键不在于它是否理想,而是它是否有用。
And even mature reuse can often be a problem. We still haven't really figured out how to deal with shared libraries that upgrade on different schedules. We've all moaned at Microsoft's DLL-hell. Just this week I found my Red Hat system got wedged when I tried to install some software and found my version dependencies were all screwed up (that was half a day down the drain.) Maybe the versioning system in .NET will solve this, but so far it's far too easy for even good people to get nailed.
即使是成熟的复用也经常会出问题。我们还没有真正的搞明白,如何处理不同版本的共享库。我们过去一直在抱怨微软的DLL(Dynamic Link Library)。就在本周,我在安装软件的时候,把我的红帽子系统搞挂了,后来发现我的版本依赖一团糟(浪费了我半天时间.)。也许.NET的版本系统能够解决这个问题,但迄今为止它还是很容易让人中招。
I've found that reuse (or avoiding duplication) within an application is vital. But reuse across applications is much tougher, primarily because an Application Boundary is primarily a social construction. That's yet more evidence that reusable frameworks are much tougher than we think, and yet more reason that we should consider less perfect alternatives - such as seedworks.
我发现复用(或避免重复)在一个应用程序中是非常重要的。但跨应用程序的重用更为困难,主要是因为应用程序边界是一种社会构成。更多的证据表明,可重用的框架比我们想象的更加困难,结合其他更多的原因,我们应该考虑不完美的替代品-如Seed Works。来解决跨应用程序的复用的问题。