Design Patterns Elements of Reusable Object-Oriented Software(一)Introduction(介绍)

1.Introduction(介绍)

Designing object-oriented software is hard,and designing reusable object-oriented software is even harder.You must find pertinent objects, factor them into classes at the rightgranularity, define class interfaces and inheritance hierarchies, and establishkey relationships among them. Your design should be  specific to the problem at hand but alsogeneral enough to address future problems and requirements. You also want toavoid redesign, or at least minimize it. Experienced object-oriented designerswill tell you that a reusable and flexible design is difficult if notimpossible to get "right" the first time. Before a design isfinished, they usually try to reuse it several times, modifying it each time

面向对象软件设计很难,面向对象的可重用的软件设计更难,.你需要发现相关的对象,在类中用准确的粒度把它分解,定义类的接口和继承的层次体系并且建立它们之间关键的关系。你需要对在手边的问题进行特殊的设计,并且大致上满足未来的地址问题和要求。你也想尽量避免重复设计,或者把它减少到最低。面向对象的软件设计经验会告诉你,如果没有在第一次时就得到正确的设计,那么实现可重复的灵活的设计是非常困难的,在你的设计完成之前,经常需要重新使用几次,修改它不完美的地方

Yet experienced object-oriented designersdo make good designs. Meanwhile new designers are overwhelmed by the optionsavailable and tend to fall back on non-object-oriented techniques they've usedbefore. It takes a long time for novices to learn what good object-oriented designis all about. Experienced designers evidently  know something inexperienced ones don't. Whatis it?

现在面向对象的设计经验可以做出更好的设计,同时新的设计也被可用的选项和倾向于依靠过去依靠的非面向对象的技术,新手花费了很长时间去学习什么是优秀的面向对象设计,有经验的设计者显然知道一些没有经验的设计者所不知的东西,那么它是什么呢?

One thing expert designers know not to dois solve every problem from first principles. Rather, they reuse solutions thathave worked for them in the past. When they find a good solution, they use itagain and again. Such experience is part of what makes them experts.Consequently, you'll find recurring patterns of classes and communicatingobjects in many object-oriented systems. These patterns solve specific designproblems and make object-oriented designs more

flexible, elegant, and ultimately reusable.They help designers reuse successful designs by basing new designs on priorexperience. A designer who is familiar

with such patterns can apply themimmediately to design problems without having

to rediscover them.

从第一原则中,一个设计能手知道不去解决每一个问题,然而,他们重用那些在过去起效的解决方案,当他们发现更好的解决方案,他们会一遍又一遍的使用它,这样的经验是他们做专家的一部分,因此,在很多面向对象的系统里,你会发现很多再现的类和通信对象的模式,这些模式解决特殊的设计问题并且使面向对象设计更加灵活,简洁,成为最终的可重复的设计,他们在过去的经验上写出新的基础设计,这帮助设计者成功地重用设计,设计者熟悉这些模式,他们可以立即把模式应用于设计问题,而不需要再去重新发现它们!

An analogy will help illustrate the point  Novelists and playwrightsrarely design theirplots from scratch Instead , they follow patterns like "Tragically Flawed  Hero" (Macbeth, Hamlet, etc.) or"The Romantic Novel" (countless romance novels).In the same way,object-oriented designers follow patterns like "represent states withobjects" and "decorate objects so you can easily add/removefeatures." Once you know the pattern, a lot of designdecisions follow automatically.

一个类似的例子会说明这个问题。小说家或剧作家从草稿中极精彩的设计其情节,反倒由此产生了榜样例如”不幸的是有缺陷的英雄”或“浪漫主义小说”,面向对象设计继承模式,如“对象代表状态”,和“布置对象,因此你可以很容易的增加或移除这些特征”,一旦你知道这个模式,很多的设计决定会自动的继承过来!

We all know the value of design experience.How many times have you had design déjà-vu—that feeling that you've solved aproblem before but not knowing exactly where or how? If you could remember thedetails of the previous  problem and howyou solved it, then you could reuse the experienceinstead of rediscovering it. However, we don't do a good job of recording experiencein software design for others to use.

我们都知道设计经验的价值,很多次你有似曾相识的设计,这种感觉是你在解决一个问题之前,但是并不知道在哪里产生,如何产生?如果你可以详细的记住以前的问题并且知道你是如何解决它的,之后你可以重用这些经验代替重新去发现它们。然而,我们不知道如何做好这些工作,去记录这些经验,在软件设计中给其他人用!

The purpose of this book is to record  experience in designing object-oriented softwareas design patterns. Each design pattern systematically  names, explains, and evaluates an importantand recurring design in object-oriented systems. Our goal is to capture designexperience in a form that people can use effectively.To this end we havedocumented some of the most important design patterns and present them as acatalog.

这本书的目的是记录在设计面向对象软件作为设计模式的经验。在面向对象系统里,每一个设计模式有重要的有组织的名字,注释,求某个值和再现的设计。我们的目的是以一种有效的形式去获得设计经验,在结束的时候我们有这些重要的设计样品的备份,作为一个模式样本再现它们。

Design patterns make it easier to reusesuccessful designs and architectures.Expressing proven techniques as designpatterns makes them more accessible to developers of new systems. Designpatterns help you choose design alternatives that make a system reusable andavoid alternatives that compromise reusability.Design patterns can even improvethe documentation and maintenance of existing systems by furnishing an explicitspecification of class and object interactions and their underlying intent.  Put simply, design patterns help a designerget a design "right" faster.

设计模式使成功的重用设计和体系结构更容易.经验证明开发者设计样品的技巧使他们更容易获得新的系统。在系统重用时,设计模式帮助你选择设计体系结构,避免体系结构在重用时陷入危险。通过提供详述的类和对象互动的说明书,和他们潜在的想法,设计模式甚至可以更好地改善备份文件和维护已经存在的系统。说的更简单一点,设计模式可以帮助设计者更快得到完美的设计。

None of the design patterns in this bookdescribes new or unprovendesigns. We have included only designs that have beenapplied more than once in different systems. Most of these designs have neverbeen documented before. They are either part of the folklore of theobject-oriented community or are elements of some successful object-orientedsystems—neither of which is easy for novice designers to learn from. Soalthough these designs aren't new, we capture them in a new and accessible way: as a catalog of designpatterns having a consistent format.


在这本书里没有描述一个新的或者未被证实多的设计模式。只含有一个在不同的系统里不止被应用一次的设计。在这之前这些设计从来没有备份,它们要么是面向对象生态的一部分,要么是一些成功的面向对象系统里的基础元素。这两者使设计新手不容易从中学习。尽管这些设计不是新的,我们获得它们用新的访问方式,使产品样本的设计模式有一致的格式,

Despite the book's size, the designpatterns in it capture only a fraction of what an expert might know. It doesn'thave any patterns dealing with concurrency or distributed programming orreal-time programming. It doesn't have any application domain-specificpatterns. It doesn't tell you how to build user interfaces, how to write devicedrivers,, or how touse an object-oriented database Each of these areas has its own patterns,,and it would be worthwhile forsomeone to catalog those too.

不管这本书的大小,设计样本仅仅是一个专家所知道的的一部分,.它没有任何处理并发性或分布式或实时的程序的样本,它没有任何具有领域特殊性的样本,它没有告诉你如何去创建用户界面,如何去写设备驱动程序,.如何去写面向对象数据库,在这个领域的每一个人都有自己的产品模式,一些人去花时间做产品样本是值得的。

 

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
《设计模式:可复用的面向对象软件的基础》(Design Patterns: Elements of Reusable Object-Oriented Software)是一本经典的计算机科学书籍,由Erich Gamma、Richard Helm、Ralph Johnson和John Vlissides联合编写。 该书首次系统地介绍了23种常见的设计模式,这些模式是面向对象软件开发的重要指导和实践。设计模式是一种对重复出现的问题的解决方案,通过它们可以提供一种通用、可重用和可扩展的设计方法,用于解决软件系统中的常见问题。 《设计模式:可复用的面向对象软件的基础》描述了每个设计模式的结构、目的、应用场景和实现方式。它通过示例代码和详细解释来帮助读者理解每种模式的用途和优缺点。 这本书的主要贡献之一是将设计模式分为三个类别:创建型、结构型和行为型模式。其中,创建型模式关注如何通过不同的方式创建对象,结构型模式关注如何组合对象以形成新功能,行为型模式关注对象之间的通信和协作方式。通过这种分类方式,读者可以更好地理解和应用设计模式。 《设计模式:可复用的面向对象软件的基础》已成为软件工程师必读的经典之作。它提供了一种设计思维的范式,可以帮助开发人员提高软件的扩展性、可读性和可维护性。无论是初学者还是经验丰富的开发人员,阅读并理解设计模式都对他们的软件设计和开发能力有很大的帮助。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值