Differences between revisions 1 and 2
Revision 1 as of 2005-08-04 09:26:24
Size: 737
Editor: flyaflya
Comment:
Revision 2 as of 2006-06-16 09:19:59
Size: 808
Editor: HoLin
Comment:
Deletions are marked like this. Additions are marked like this.
Line 44: Line 44:

=== 反馈 ===
 * 看例子感觉和接口很像 --[:holin: HoLin]

-- flyaflya [DateTime(2005-08-04T09:26:24Z)] TableOfContents

1. Template Method(模板方法)

1.1. 意图

定义一个操作中的算法的骨架,而将一些步骤延迟到子类中。

1.2. 代码

   1 class Base:
   2     def doAll(self):
   3         self.doThis()
   4         self.doThat()
   5     
   6 class Foo(Base):
   7     def doThis(self):
   8         print "do this"
   9     def doThat(self):
  10         print "do that"
  11 
  12 #测试
  13 Foo a
  14 a.doAll()
  15 #输出
  16 #do this
  17 #do that

1.3. 例子

声明

   1 

使用情景

   1 

1.4. 特殊说明

1.5. 反馈

  • 看例子感觉和接口很像 --[:holin: HoLin]

TemplateMethodPattern (last edited 2009-12-25 07:14:52 by localhost)