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

2023-05-16

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.

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

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Design Patterns Elements of Reusable Object-Oriented Software(一)Introduction(介绍) 的相关文章

  • 从现有数组创建新结果

    如果我有一个如下所示的示例数据 我需要从结果数组中获取 FinalResult 数组 let result type Science link www educatorsector com type Sports News link www
  • CMake:将为 lib 构建的对象文件重用到另一个 lib 目标中

    我正在尝试将我的项目转移到CMake 同时对编译过程进行一些优化 这是交易 我有几个子目录 必须 每个子目录都编译成静态库 这有效 我想将每个子目录中的所有目标文件收集到另一个更大的 完整的静态库中 它看起来像这样 libBig a mad
  • Javascript:从已实例化的对象与原型创建对象

    我有一个相当学术的问题 并不特别适用于我正在做的任何事情 我只是真的想知道答案 假设我们在全局命名空间中有一个简单的对象定义 如下所示 TestObject function 它的原型中添加了一个方法 可以实例化为新对象本身 TestObj
  • stdClass 类的对象无法转换为字符串

    我现在在使用 PHP 时遇到问题 收到此错误 Object of class stdClass could not be converted to string当我在我的网站中运行这部分代码时发生错误 function myaccount
  • Java:如何复制对象数组?

    现在 我有一个 Point 对象数组 我想制作一个COPY该数组的 我尝试过以下方法 1 Point temp mypointarray 2 Point temp Point mypointarray clone 3 Point temp
  • Object.assign 方法不绑定“this”

    我正在尝试绑定this变量到一个新对象 function Parent sub component constructors this components node function this name jordan subcompone
  • 在读取之前设置未定义的 javascript 属性

    var tr tr SomeThing SomeThingElse console log tr SomeThing SomeThingElse console log tr Other undefined tr get function
  • 如何将对象转换为传递给函数的类型?

    这不会编译 但我想做的只是将对象转换为传递给函数的 t public void My Func Object input Type t t object ab TypeDescriptor GetConverter t ConvertFro
  • 使用另一个对象数组过滤对象数组

    这个问题与这个问题类似Jquery 过滤带循环的对象数组 https stackoverflow com questions 30998424 jquery filter array of object with loop但这次我需要使用对
  • 如何在Java中计算对象的数字年龄[关闭]

    Closed 这个问题需要多问focused help closed questions 目前不接受答案 我想知道Java中对象的年龄 当我们使用new关键字时 Java中用户定义的对象被创建 但是什么时候它会被销毁 是跨越JVM的perm
  • PHP 对象创建和内存使用

    一个基本的虚拟类 class foo var bar 0 function foo function boo echo memory get usage echo n foo new foo echo memory get usage ec
  • JavaScript 数组和对象除了 .length 属性之外有什么区别?

    我认为 JS 数组只是一个哈希映射 它只接受整数值作为键 length 属性只返回最大索引 1 这是正确的吗 还有其他区别吗 您错了 数组可以有任何你想要的键 此外 他们还继承了Array原型
  • 如何在没有引用的情况下复制对象?

    PHP5 OOP 有据可查对象通过引用传递 http php net manual en language oop5 references php默认情况下 如果这是默认的 在我看来 有一种非默认的方式可以在没有参考的情况下进行复制 如何
  • 递归修剪对象中所有元素的更好方法?

    如果我有一个像这样的物体 const obj field subfield innerObj a asdasd asdas innerArr s ssad innerArrObj b adsad 我想出了这样的东西 const trimFi
  • 如何选择面积最大的对象?

    我用过bwconvhull检测图像的某个部分 正如您在图像中看到的那样 有许多具有特定质心的对象 我想做的是检测面积最大的物体 左起第一个大物体 并忽略其他物体 我应该遵循哪种方法 我将非常感谢您的帮助 以下是代码 由于我仍在努力 所以写得
  • 将值添加到对象类型c#

    我有这样的对象 object rt new page 1 现在我如何向该对象添加新值 我的意思是这样的 rt code 5 这怎么可能呢 听起来更像是你想要一个Dictionary
  • 将相同的多个对象推送到多个数组中

    这是后续使3个数组相互对应 第一个是对象名称 https stackoverflow com questions 57564488 make 3 arrays correspond to each other with the first
  • 检测未定义的对象属性

    如何检查 JavaScript 中的对象属性是否未定义 检查属性值是否为特殊值的常用方法undefined is if o myProperty undefined alert myProperty value is the special
  • 为什么这个对象的“forEach 不是函数”?

    这可能真的很愚蠢 但我不明白为什么这不起作用 var a cat large a forEach function value key map console log value 未捕获的类型错误 a forEach 不是函数 http j
  • Ruby 元编程方法列表?

    刚刚开始学习 Ruby 元编程 看看 Object methods 我得到 Object methods gt allocate new superclass freeze lt gt lt lt gt gt to s included m

随机推荐

  • Linux开机关机执行脚本方法

    1 在 etc rc d init d 下创建脚本 xff0c 要遵守service script的标准 xff1b 例如 xff1a vi etc rc d init d gfs bin bash case 34 1 34 in rest
  • Ubuntu 出现apt-get: Package has no installation candidate问题

    今天在安装软件的时候出现了Package has no installation candidate的问题 xff0c 如 xff1a apt get install lt packagename gt Reading package li
  • 深度学习(2):DenseNet与图片文字识别

    目的 xff1a 基于深度学习算法DenseNet对图片进行文字识别 xff0c 即OCR转换为文字 xff0c 并将图片进行可视化输出 一 DenseNet算法 DenseNet的基本思路与ResNet一致 xff0c 但是它建立的是前面
  • 安装配置vscode

    远程Linux服务器越来越慢 换成vscode开发好了 xff0c 费时操作放在后台运行 xff0c 不影响前端界面 安装VSCode Visual Studio Code 离线安装扩展 先在 Extensions for Visual S
  • Postman传入date类型

    字符串输入格式 xff1a 2021 08 01 00 00 00 Date输入格式 xff1a 2019 09 09 11 20 20 插入到数据库中是DATE类型 xff1a 先获取到参数转为String类型 xff0c 在格式化为Da
  • 《Activity显示界面历险记》—说说View的那些理不清的关系

    前言 在Activity显示View的过程中 xff0c 有一些重要的角色总让人理不清 xff0c 比如PhoneWindow DecorView ViewRootImpl 也常常有面试题会问到 xff0c 他们四者之间的关系 xff1f
  • smartBi数据源连接与业务主题及七大数据集及透视分析与仪表盘四大分析展示经验总结

    smartBi经验总结 数据门户 电脑主题的资源发布后 xff0c 发布的资源可以在数据门户中看到 xff0c 数据门户界面包含 xff1a 首页 xff0c 报表展示目录 xff0c 报表展示明细资源 首页的设置在系统运维中 系统选项 公
  • java 中 Color类

    Color类 Color类是用来封装颜色的 xff0c 在上面的例子中多次用到 使用Color对象较为简单的方法是直接使用Color类提供的预定义的颜色 xff0c 像红色Color red 橙色Color orange等 xff1b 也可
  • C语言位运算符:与、或、异或、取反、左移和右移

    语言位运算符 xff1a 与 或 异或 取反 左移和右移 位运算是指按二进制进行的运算 在系统软件中 xff0c 常常需要处理二进制位的问题 C语言提供了6个位操作运算符 这些运算符只能用于整型操作数 xff0c 即只能用于带符号或无符号的
  • android 打开蓝牙设备 显示已经配对的蓝牙设备 ,并将已配对的蓝牙设备显示在textview中

    xff08 1 xff09 要想使用android 手机的Bluetooth xff0c 需要在androidmanifest文件中加入使用蓝牙的权限 lt uses permission android name 61 34 androi
  • iOS 7 点击按钮切换视图

    xff08 1 xff09 创建一个项目 xff0c 名字为切换视图 xff08 2 xff09 打开Main storyboard文件 xff0c 将视图中的ViewController视图控制器拖动到画布中 xff08 3 xff09
  • Javaweb 入门测试程序(jsp)

    关于进行jsp程序开发的入门测试小程序 xff08 1 xff09 必须的工具软件 java开发工具包jdk 需要进行环境变量的设置 xff0c 有Java开发基础的人这一步一看就懂 xff01 xff08 2 xff09 安装MyEcli
  • 自媒体平台运营的感悟

    1 关键是自媒体平台的定位 西游记中唐僧有着坚定的志向 西天取经 xff0c 普渡众生 抱着这样的初心和宗旨 xff0c 打造了自己的取经团队 一路上历经九九八十一难 xff0c 初心不改 xff0c 终于到达西天 xff0c 取得真经 x
  • 排序方法总结(1)冒泡排序 选择排序

    排序方法是一种基本的 重要的算法 xff0c 排序的方法有很多 xff0c 现把一些基本排序方法的算法和c 代码列出如下 xff0c 供大家思考 xff0c 借鉴 xff0c 进步 在进行排序之前首先要做的一件事就是选择排序的准则 xff0
  • 排序方法总结(2)插入排序

    插入排序 插入排序类和大家玩的纸牌游戏有些类似 xff0c 在发牌的过程的过程中用右手起的牌 xff0c 总是和左手里的排进行比较 xff0c 然后放在恰当的位置 这就是插入排序的思想 以数组为例 xff0c 其算法是 xff1a xff0
  • 关闭IDEA保存后自动添加空格

    IDEA保存后会给每行自动添加空格 xff0c 关闭这个功能
  • 排序方法总结(3)希尔排序

    希尔排序 希尔排序是对插入排序的改进 xff0c 对中等规模的数据排序效率较高 xff01 交换的次数变得少了 xff0c 效率就高了 希尔排序的算法 1 相距为 k 的数据进行比较 xff0c 若不符合排序的条件 xff0c 就进行交换
  • 求阶乘的几种方法

    求阶乘的几种方法 xff08 1 xff09 常规求阶乘 利用循环即可求出 include lt stdio h gt int main int m n i sum 61 1 printf 34 please input one numbe
  • C++sort函数的用法

    C 43 43 sort 函数的用法 近来看了c 43 43 标准库这本书 xff0c 学到了很多 xff0c 就把这其中的一点 C 43 43 sort 函数的用法写下来和大家分享吧 xff01 xff08 一 xff09 为什么要用c
  • Design Patterns Elements of Reusable Object-Oriented Software(一)Introduction(介绍)

    1 Introduction xff08 介绍 xff09 Designing object oriented software is hard and designing reusable object oriented software