《深入淺出設計模式》的原文摘录

  • 針對接口編程,而不是針對實現編程 (查看原文)
    星塵子 1赞 2013-01-12 21:19:50
    —— 引自第11页
  • 針對超類型編程 (查看原文)
    星塵子 1赞 2013-01-12 21:19:50
    —— 引自第11页
  • The Hollywood Principle Don't call us, we'll call you. > The high-level components give the low-level components a "don't call us, we'll call you" treatment. > The Hollywood Principle gives us a way to prevent "dependency rot". (依赖腐败) (查看原文)
    小志的冷色调 1赞 2013-04-15 23:42:16
    —— 引自第296页
  • The connection between the Hollywood Principle and the Template Method Pattern is probably somewhat apparent: when we design with the Template Method Pattern, we're telling subclasses, "don't call us, we'll call you." (查看原文)
    小志的冷色调 1赞 2013-04-15 23:42:16
    —— 引自第296页
  • 分开变化和不会变化的部分 针对接口(超类型)编程,而不是针对实现编程 (查看原文)
    Showing V1.4.1 2012-06-24 22:05:31
    —— 引自第10页
  • 开放-关闭原则:类应该对扩展开放,对修改关闭。 (查看原文)
    Showing V1.4.1 2012-07-01 19:24:00
    —— 引自第86页
  • 系統中的某部分改變不會影響其他部分 (查看原文)
    星塵子 2013-01-12 21:13:43
    —— 引自第9页
  • 觀察者模式 = 出版者 + 訂閱者。 (查看原文)
    星塵子 2013-01-14 20:10:02
    —— 引自章节:觀察者模式
  • 設計原則三:爲了交互對象之間的松耦合設計而努力。 (查看原文)
    星塵子 2013-01-14 20:18:41
    —— 引自章节:觀察者模式
  • 設計原則四:類應該對擴展開放,對修改關閉。 (查看原文)
    星塵子 2013-01-14 20:26:57
    —— 引自章节:裝飾者模式
  • The Decorator Pattern attaches additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. (查看原文)
    小志的冷色调 2013-04-03 07:23:13
    —— 引自第91页
  • The Simple Factory isn't actually a Design Pattern; it's more of a programming idiom. (查看原文)
    小志的冷色调 2013-04-04 08:56:23
    —— 引自第117页
  • A factory method handles object creation and encapsulates it in a subclass. This decouples the client code in the super class from the object creation code in the subclass. abstract Product factoryMethod(Arguments args) > 1. A factory method is abstract, so the subclasses are counted on to handle object creation. > 2. A factory method returns a Product that is typically used within methods defined in the supercalss. > 3. A factory method isolates the client (the code in the superclass, like orderPizza()) from knowing what kind of concrete Product is actually created. > 4. A factory method may be parameterized (or not) to select among several vaiations of a Product. (查看原文)
    小志的冷色调 2013-04-04 09:52:08
    —— 引自第125页
  • All factory patterns encapsulate object creation. The factory Method Pattern encapsulates object creation by letting subclasses decide what objects to create. (查看原文)
    小志的冷色调 2013-04-04 10:35:23
    —— 引自第131页
  • The Factory Method pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. > As with every factory, the Factory Method Pattern gives us a way to encapsulate the instantiations of concrete types. Looking at the class diagram below, you can see that the abstract Creator gives you an interface with a method for creating objects, also known as "factory method." Any other method implemented in the abstract Creator are written to operate on products produced by the factory method. Only subclasses actually implement the factory method and create products. (查看原文)
    小志的冷色调 2013-04-04 10:55:30
    —— 引自第134页
  • Design Principle Depend upon abstraction. Do not depend upon concrete classes. > The dependency Inversion Principle makes and stronger statement about abstraction. Its suggests that our high-level components should not depend on our low-level components; rather, they should both depend on abstraction. ( A "high-level" component is a class with behavior defined in terms of other, "low-level" components.) (查看原文)
    小志的冷色调 2013-04-04 11:54:59
    —— 引自第139页
  • No variable should hold a reference to a concrete class. > If you use new, you'll be holding a reference to a concrete class. Use a factory to get around that. No class should derive from a concrete class. > If you derive from a concrete class, you're depending on a concrete class. Derive from an abstraction, like an interface or an abstraction class. No method should override an implemented method of any of its base classes. > If you override an implemented method, then your base class wasn't really an abstraction to start with. Those methods implemented in the base class are meant to be shared by all your subclass.. (查看原文)
    小志的冷色调 2013-04-04 12:41:12
    —— 引自第143页
  • The Abstract Factory Pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes. (查看原文)
    小志的冷色调 2013-04-04 16:57:24
    —— 引自第156页
  • The concise definition of the pattern: > The Singleton Pattern ensures a class has only one instance, and provides global point of access to it. > What's really going on here ? We're taking a class and letting it manager a single instance of itself. We're also preventing any other class form creating a new instance on its own. To get an instance, you've got to go through the class itself. >We're also providing a global access point to the instance: whenever you need an instance, just query the class and it will hand you back the single instance. As you've seen, we can implement this so that the Singleton is created in a lazy manner, which is especially important for resource intensive objects. (查看原文)
    小志的冷色调 2013-04-05 09:33:07
    —— 引自第177页
  • By adding the synchronized keyword before getInstance(), we force every thread to wait its turn before it can enter the method. That is, no two threads may entry the method at the same time. ……it looks fairly expensive to synchronize the getInstance() method. And the following is some way to fixed it. 1. Do nothing if the performance of getInstance() isn't critial to your application. 2. Move to an eagerly created instance rather than a lazily. (查看原文)
    小志的冷色调 2013-04-05 09:41:15
    —— 引自第180页
<前页 1 2 3 后页>