《设计模式》的原文摘录

  • 将系统分解成对象集合。因为要考虑许多因素:封装、粒度、依赖关系、灵活性、性能、演化、复用等等,它们都影响着系统的分解,并且这些因素通常还是互相冲突的。 (查看原文)
    一分钟都市 1赞 2016-07-19 23:53:57
    —— 引自第8页
  • 类型(type) 是用来标识特定接口的一个名字。 (查看原文)
    一分钟都市 1赞 2016-07-19 23:53:57
    —— 引自第8页
  • 动态绑定是指发送的请求直到运行时刻才受你的具体的实现的约束。 (查看原文)
    一分钟都市 1赞 2016-07-19 23:53:57
    —— 引自第8页
  • 进一步讲,动态绑定允许你在运行时刻彼此替换有相同接口的对象。这种可替换性就称为多态(polymorphism),它是面向对象系统中的核心概念之一。 (查看原文)
    一分钟都市 1赞 2016-07-19 23:53:57
    —— 引自第8页
  • 抽象类(abstract class)(与之对应的还有非抽象类称为具体类(concrete class)。)的主要目的是为它的子类定义公共接口。一个抽象类将把它的部分或全部操作的实现延迟到子类中,因此,一个抽象类不能被实例化。 (查看原文)
    一分钟都市 1赞 2016-07-19 23:53:57
    —— 引自第8页
  • 子类能够改进和重新定义它们父类的操作。更具体地说,类能够重定义(override)父类定义的操作,重定义使得子类能接管父类对请求的处理操作。 (查看原文)
    一分钟都市 1赞 2016-07-19 23:53:57
    —— 引自第8页
  • 混入类(mixin class)是给其他类提供可选择的接口或功能的类。它与抽象类一样不能实例化。混入类要求多继承 (查看原文)
    一分钟都市 1赞 2016-07-19 23:53:57
    —— 引自第8页
  • 针对接口编程,而不是针对实现编程。 (查看原文)
    xyb 5赞 2011-01-26 14:56:37
    —— 引自第12页
  • 优先使用对象组合,而不是类继承。 (查看原文)
    xyb 5回复 6赞 2011-01-26 14:58:47
    —— 引自第13页
  • 一个对象可以有许多类型,并且不同的对象可以共享同一个类型。 (查看原文)
    laichendong 1回复 2012-02-12 22:15:24
    —— 引自第9页
  • 对象的某部分接口可以用某个类型来刻画,另一部分接口由其他的类型来刻画 (查看原文)
    laichendong 1回复 2012-02-12 22:15:24
    —— 引自第9页
  • Program to an interface, not an implementation Don't declare variables to be instances of particular concrete classes. Instead, commit only to an interface defined by an abstract class (查看原文)
    冷艳锯 2012-05-02 22:22:17
    —— 引自第18页
  • This dependency limits flexibility and ultimately reusability. One cure for this is to inherit only from abstract classes, since they usually provide little or no implementation. (查看原文)
    冷艳锯 2012-05-02 22:25:25
    —— 引自第19页
  • Favor object composition over class inheritance (查看原文)
    冷艳锯 2回复 2012-05-02 22:29:30
    —— 引自第20页
  • Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receivingobjects and pass the request along the chain until an object handles it. (查看原文)
    润物无声 2012-12-05 10:50:41
    —— 引自第251页
  • 1. Reduced coupling.The pattern frees an object from knowing which other object handles arequest. An object only has to know that a request will be handled"appropriately." Both the receiver and the sender have no explicit knowledge of each other, and an object in the chain doesn't have to know about the chain's structure. As a result, Chain of Responsibility can simplify object interconnections. Instead of objects maintaining references to all candidate receivers, they keep a single reference to their successor. 2. Added flexibility in assigning responsibilities to objects.Chain of Responsibility gives you added flexibility in distributing responsibilities among objects. You can add or change responsibilities for handling a request by adding to or otherwise changing the chain at run-time. ... (查看原文)
    润物无声 2012-12-05 10:50:41
    —— 引自第251页
  • 关于Builder的协作过程: 1、客户创建Director对象,并用它所想要的Builder对象进行配置。 2、一旦产品部件被生成,导向器就会通知生成器。 3、生成器处理导向器的请求,并将部件添加到该产品中。 4、客户从生成器中检索产品。 (查看原文)
    ziyoudefeng 2012-12-25 10:50:00
    —— 引自第65页
  • Director notifies the builder whenever a part of the product should be built. (查看原文)
    ziyoudefeng 2012-12-25 10:50:00
    —— 引自第65页
  • C++中的工厂方法都是虚函数并且常常是纯虚函数。一定要注意在Creator的构造器中不要调用工厂方法——在ConcreteCreator中该工厂方法还不可用。 (查看原文)
    ziyoudefeng 2012-12-25 13:34:21
    —— 引自第74页
  • Factory methods in C++ are always virtual functions and are often pure virtual. Just be careful not to call factory methods in the Creator's constructor—the factory method in the ConcreteCreator won't be available yet. (查看原文)
    ziyoudefeng 2012-12-25 13:34:21
    —— 引自第74页
<前页 1 2 后页>