一叶知秋 浅尝DesignPattern
浅尝DesignPattern
UML:
· AbstractClass ()
·defines abstract primitive operations that concrete subclasses define to implement steps of an algorithm
·定义一个抽象的原始操作 来使子类实现算法步骤
·implements a template method defining the skeleton of an algorithm The template method calls primitive operations as well as operations defined in AbstractClass or those of other objects
·实现一个定义了算法节后的模版方法 该模版方法需要原始操作和抽象类中定义的操作
· ConcreteClass ()
·implements the primitive operations to carry out subclass specific steps of the algorithm
·实现原始操作 来实现子类的特殊操作
abstract class AbstractClass
{
public abstract void PrimitiveOperation ();
public abstract void PrimitiveOperation ();
public void TemplateMethod()
{
PrimitiveOperation ();
PrimitiveOperation ();

Console WriteLine( );
}
}
#region Template
AbstractClass aA = new ConcreteClassA();
aA TemplateMethod();
AbstractClass aB = new ConcreteClassB();
aB TemplateMethod();
#endregion
模版方法模式:定义一个操作中的算法股价 而将一些步骤延迟到子类中 模版方法是的子类可以不改变一个算法的结构即可重定义该算法的某些特定步骤
lishixinzhi/Article/program/net/201311/13987