设计模式之Frameworks 框架(二)

2014-11-24 08:24:17 · 作者: · 浏览: 2
therwise even aminor change to the framework will have
major repercussions.
更长远的说,因为应用依赖为它所设计的框架,框架的接口是特别敏感的。在框架逐步演化的过程中,应用也随着它而演化。连接是非常重要的,否则框架一个很小的改变也会产生很大的影响。
The design issues just discussed are mostcritical to framework design. A framework that addresses them using design patternsis far more likely to achieve high levels
of design and code reuse than one thatdoesn't. Mature frameworks usually incorporate several design patterns. The patterns help make the framework's architecture suitable to many differentapplications without redesign.
在设计议题中,极重要的是框架的设计。地址使用设计模式的框架很容易达到很高的水平,它是设计和代码的重用所达不到的!成熟的设计模式通常包含了几个设计模式,在不重用设计的情况下,模式使框架的体系结构适合更多不同的应用。
An added benefit comes when the framework is documented with the design patterns it uses [BJ94]. People who know the patterns gain insight into the framework faster.
Even people who don't know the patterns canbenefit from the structure they lend to the framework's documentation. Enhancingdocumentation is important for all
types of software, but it's particularly important for frameworks. Frameworks often pose a steep learning curve that must be overcome before they're useful.While design patterns might not flatten the learning curve entirely, they can make it less steep by making key elements of the framework's design more explicit.
一个额外的好处是框架是设计模式所用的文件。人们都知道模式洞察框架更快!即使人们不知道模式可以从这个结构中获益,适合于框架文件。对所有的软件来说提高它的使用是非常重要的,对框架来说它显得特别的重要!框架的学习是一个陡峭的学习曲线,在使用它之前必须克服。然而设计模式也不是一个完全平坦的曲线,可以明确在定制框架时更关键的因素,就可以成功了!
Because patterns and frameworks have some similarities, people often wonder how or even if they differ. They are different in three major ways:
因为模式和框架有很多相似的地方,我们经常为它们的不同之处感到惊讶!它们不同在这三个主要的方面。
1. Design patterns are more abstract than frameworks. Frameworks can be embodied in code, but only examples of patterns can be embodied in code.
A strength of frameworks is that they can be written down in programming languages and not only studied but executed and reused directly. In contrast,
the design patterns in this book have to beimplemented each time they're used. Design patterns also explain theintent, trade-offs, and consequences
of a design.
1)设计模式比框架更抽象。框架可以用代码来体现。只是模式用代码实现的一个例子。一个强大的框架可以用程序语言写下来,不仅是学习和研究和有目的的重用!相比之下,在这本书中的设计模式在使用它们的时候都被实现了。设计模式也解释了意图.、权衡和设计的影响。
2. Design patterns are smaller architectural elements than frameworks. Atypical framework contains several design patterns, but the reverse is never
true.
设计模式是比框架还小的体系结构元素。框架包含了几种设计模式,但是反过来确实不正确的。
3. Design patterns are less specialized than frameworks. Frameworks always have a particular application domain. A graphical editor framework might be used in a factory simulation, but it won't be mistaken for a simulation framework. In contrast, the design patternsin this catalog can be used in nearly any kind of application. While more specialized design patterns than ours are certainly possible (say,design patterns for distributed systems or concurrent programming), even these wouldn't dictate an
application architecture like a framework would.
设计模式没有框架那么专业。框架总是有特别的应用域。图像编辑程序框架可能被工厂模拟。但是这种模拟不会因为是框架而犯错。相比之下,设计模式可以被应用在各种应用的设计样本中。而更专业的设计模式没有了(设计模式的分布系统或并行 编程),就像一个框架这不决定应用结构。
Frameworks are becoming increasingly commonand important. They are the way that object-oriented systems achieve the mostreuse. Larger object-oriented
applications will end up consisting oflayers of f