//工厂方法的理解比较容易,重要还是如何在实践中应用。以下范例比较经典: 基本概念 FactoryMethod是一种创建性模式,它定义了一个创建对象的接口,但是却让子类来决定具体实例化哪一个类.当一个类无法预料要创建哪种类的对象或是一个类需要由子类来指定创建的对象时我们就需要用到Factory Method 模式了.简单说来,Factory Method可以根据不同的条件产生不同的实例,当然这些不同的实例通常是属于相同的类型,具有共同的父类.Factory Method把创建这些实例的具体过程封装起来了,简化了客户端的应用,也改善了程序的扩展性,使得将来可以做最小的改动就可以加入新的待创建的…
2012-01-03 19:16 · Thinking in patterns( 阅读笔记)
An application framework allows you to inherit from a class or set of classes and create a new application, reusing most of the code in the existing classes and overriding one or more methods in order to customize the application to your needs. A fundamental concept in the application framework is …
2012-01-01 20:50 · Thinking in patterns( 阅读笔记)
Although GoF says that Policy is just another name for strategy, their use of Strategy implicitly assumes a single method in the strategy object – that you’ve broken out your changing algorithm as a single piece of code. .... It also seems generally useful to distinguish Strategies with single meth…
2012-01-01 15:58 · Thinking in patterns( 阅读笔记)