返回目录
模版模式,又被称为模版方法模式,它可以将工作流程进行封装,并且对外提供了个性化的控制,但主流程外界不能修改,也就是说,模版方法模式中,将工作的主体架构规定好,具体类可以根据自己的需要,各自去实现,这可能会让我们想到策略模式,两者有着本质的区别。
何时能用到它?
我们看一下策略模式的应用场景
1、 多个类只区别在表现行为不同,可以使用Strategy模式,在运行时动态选择具体要执行的行为。
2、 需要在不同情况下使用不同的策略(算法),一般会定义一个接口规范,使用不同的策略方式去实现它
3、 对客户隐藏具体策略(算法)的实现细节,彼此完全独立。
而模版方法模式的应用场景
1、多个类区别在于主流程中的某个细节
2、客户可以自已实现模版里的抽象方法
3、对客户隐藏具体的实现流程(方法的组合的顺序)
模版模式的结构图
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaQAAAFFCAIAAAAsNg5FAAAgAElEQVR4nO2d6VcTWbu3az3nfDqf37/jrPOeXutt28dWUbCx256csG2727YBAZFB0UbEEQUnEAUZFHEWRUVQMCi20CgqitqiMhjDEMYwhIxVyd5VxfuhQhGSEBIyVBXc17oXq1KpVG3gx1V771QKYhQAAGAWQAjdAAAAAH8AsgMAYFYAsgMAYFYAsgMAYFYAsgMAYFYAsgMAYFYAsgMAYFYAsgMAYFYAsgMAYFYAsgMAYFYAsgMAYFYAsgMAYFYAshMdw8NDdU9qyu/e6u5WbkuIjI8NPZV1VC5viY8NhWX/LJ/KOlpaco0kjd3dSqHjAHgNkJ240Gk1u3dtvVF8SS5vUWsMvQP6ATU1qKYGR7gycTXEl2ZCDWtMw1rbUmvNaq1ZrbPUiF1p9Lal1SNLGcZLZ13G8dLzRWKuDNZFYQOFjXZFUpg0cUVzRVmXebxM1oUsZUaMTSE8oTBftKVomrUUM16MdbGW6upS9vZ2d7Qr0lKT8/MydVqN0LkAvADITixwf1rd3UrVkFHRrf/Qpmkaq+Y2TXO7prld09KubWnXtnRoW8fqY+dYKXUflTq5UifvstSnbkspuvWKbr2iR9/Wo2/r0bf36Nt79e29+o5eA1edfZZS9h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Y7lzPr8yS10dXUtWrSoq6vLxfPqDMArSXKCmEPmCZBD7zKbc+hb2dnDnUsXjeHKeXUGMNnp1IuIOWSeADn0IrM8hwLITqvVhoeHL1q0KDw8fPacUX2NmEPmCZBDaSHmHAomu5qaGgiZFxFzyDwBcigtxJxDYWTn7nthwJSIOWSeADmUFmLO4aSyS0qMMZlM/mwK4AliDpknQA6lhZhzOKns0lKTVf19/mwKMG0wQglbI0QbMk+AHEoIkedwUtkVFpxqbHztz6YA06a7W5l2MFm0IfMEyKGEEHkOJ5Vd3ZOaG8WX/NkUYNo8rLp36WKBaEPmCZBDCSHyHE4qO5I0pqUm67Qaf7YGmAYYoQMpO16+fCHakHkC5FAqiD+Hzi4vbG56l5+X6bemANPjRvGlklvXWyYidKO8CeRQEog/h1NcS1105Vx9fZ1/mgJMA7m8JePYAZuEyeVyodvlZSCHIkcSOZxCdiRpzDye+rDqnn9aA7hFfX3dodRdNgOHlpaW/v5+oZvmZSCHYkYqOZz6U3IYofK7tzKPp3Z3K/3QIMAVhoeH8vMyz+RnvX37j03CPn36JHTrfALkUIRIK4eufiS4o11x7Mi+lH2JpSXXKmVlUEJV+d1bx47s27t7W9UDWYsjfBoXwYEciqSkmEP37n8wPDx069a1K5cLoYSqoqsXnjypdRgvcSbMF0AOBS8p5nCaN3uZ7JsEhEJsk8H+QeifOmCLmHM4/TtbKZVKoX+wQEtLS0tra2tvb68XMyEtIIciQfw59O1tSwEAAEQCyA4AgFkByA4AgFkByA4AgFkByA4AgFkByA4AgFkByA4AgFkByA4AgFnB/wchJSxKV82d9gAAAABJRU5ErkJggg==" alt="" />
模版模式实现说明
OrderGenerator:模版模式基类,实现了某种业务的完整流程,其中一些核心方法已经实现,一些个性化方法被声明为抽象方法,让子类去实现。
B2COrderGenerator:B2C业务中去实现抽象方法
C2COrderGenerator:C2C业务中去实现抽象方法
模版模式的C#实现
/// <summary>
/// 模版核心类
/// </summary>
abstract class OrderGenerator
{
/// <summary>
/// 核心处理流程
/// </summary>
public void Excute()
{
InsertData();
ProcessException();
InsertLog();
}
void InsertData()
{
Console.WriteLine("写数据对外面隐藏");
}
void InsertLog()
{
Console.WriteLine("写日志对外面隐藏");
}
/// <summary>
/// 异常处理逻辑,对外面开放,可以自己建立自己的异常规范
/// </summary>
protected abstract void ProcessException();
}
/// <summary>
/// b2c项目业务处理方法
/// </summary>
class B2COrderGenerator : OrderGenerator
{
protected override void ProcessException()
{
Console.WriteLine("b2c项目中订单的异常处理方式");
}
}
/// <summary>
/// c2c项目业务处理方法
/// </summary>
class C2COrderGenerator : OrderGenerator
{
protected override void ProcessException()
{
Console.WriteLine("c2c项目中订单的异常处理方法");
}
}
调用方法
#region 模版方法调用
OrderGenerator orderGenerator = new B2COrderGenerator();
orderGenerator.Excute();
#endregion
程序截图
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAANgAAABGCAIAAAAhLs2JAAAMVklEQVR4nO2c6W9VxxXA79c4pAUCaYCWAjarwTabWbymWUgBYzazua1aqUgNIewJZrfBGC/sYKjSqoloqBKhRq1aVapkS+9bwxKplir1H2jtSFUAG+P3DKa3H85j3niWM2fmLXbqORqhueeec+bMnN+buzzzgqycHcm0F6fveHH6u9BGzXh31Iydo2bsHDVz50vx9t5Ls977FrTZu77N2pzdo6Hl7h6du3tM7p4xuXvGzN0zZu6esXP3jp23d+y8vS9Dy9v3ct6+cXn7xuXvG5e/f1z+/vH5+8cX7B9fcGB8wYFXCg68Mh/a+99ZEG+vLvjg1YXxNmHRBxMWHYQ2cfHBiYtrJi6umVhYM6mwZlLhoUmFh7675Hlbevh7rC07Mhna8iOTlx/9PrSio1OKjk4pOjal6NiU4mNTi49NLT4+teT41JLj06CVnphWeiK79ER22Ynsstrsstqcstqc8tqc8rrp5XXTX4u3Ga+dnPGDeJv5+inWZr1xatYb9bPeqJ/9JrTTs988PectaA1zVjTksvb2mbnP27wfNsbbysa8lY15K5vyVjblrWrKX9WUv6o5f3Vz/urmgtXNBatbCipaCipa5le0zF/TMn/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4vD7iEyI24nRGHEJVHDYgoi7EEGULZEpyORRUhrRkvLfR0T0DmIEQlYqwdJ5BbSbSwo9OtaF4B5EtST52zd0Ywcb2UwJInKWCCKulPX4ZxUnD5/CyJUMg0ikhFfqdhrK0BRLBxCNQwvMyVx6EEVx+31ERKnU41W38kLGdbOkzFfAyBhfZg6ZuJcgyNSOSARaVy2r8lMsjYMqR8QtdR2Kr5dhCiJeIXoyqQWR71vRxgSxH+ni/PuIgf6eHd/AjPYO+dA/EpTk8Skoc0BAROJ4EBPi8PuIxlNpXV86hc6n5LMRbnvjlcTPnk7pQUxIMn+P6LCOKdnMbIez3XEzJh7EhCi/WaFcrQKnAiMdJDgxH8q4RHu66HIjJulZBPkfkKNKDxPEc+8AAAAASUVORK5CYII=" alt="" />
返回目录
-
设计模式:模版模式(Template Pattern)
android中的Activity框架,View框架中大量的on函数基本上都应用到了Template模式,掌握这一模式对于理解这些框架大有裨益. 模版模式 又叫模板方法模式,在一个方法中定义一个算法的 ...
-
设计模式:模版模式(Template Pattern)-转
模版模式 又叫模板方法模式,在一个方法中定义一个算法的骨架,而将一些步骤延迟到子类中.模板方法使得子类可以在不改变算法结构的情冴下,重新定义算法中的某些步骤. 我们使用冲泡咖啡和冲泡茶的例子 加工流程 ...
-
设计模式 - 模板方法模式(template method pattern) JFrame 具体解释
模板方法模式(template method pattern) JFrame 具体解释 本文地址: http://blog.csdn.net/caroline_wendy 參考模板方法模式(templ ...
-
设计模式 - 模板方法模式(template method pattern) 排序(sort) 具体解释
模板方法模式(template method pattern) 排序(sort) 具体解释 本文地址: http://blog.csdn.net/caroline_wendy 參考模板方法模式(tem ...
-
设计模式 - 模板方法模式(template method pattern) 具体解释
模板方法模式(template method pattern) 详细解释 本文地址: http://blog.csdn.net/caroline_wendy 模板方法模式(template metho ...
-
java设计模式 模板方法模式Template Method
设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了可重用代码.让代码更容易被他人理解.保证代码可靠性.毫无疑问,设计模式于己 ...
-
C#设计模式-模板方法模式(Template Method)
概念 模板指一些可以套用的公共内容,例如网页模板是当网站中有许多页面版式色彩相同的情况下,将其定义为网页模板,并定义其中部分可编辑,部分不可编辑,那么在利用网页模板制作其他页面时就会很方便,不易出错. ...
-
瑞幸咖啡还是星巴克,一杯下午茶让我明白 设计模式--模板方法模式(Template Method Pattern)
简介 Define the skeleton of an algorithm in an operation,deferring some steps to subclasses.Template M ...
-
[Head First设计模式]云南米线馆中的设计模式——模版方法模式
系列文章 [Head First设计模式]山西面馆中的设计模式——装饰者模式 [Head First设计模式]山西面馆中的设计模式——观察者模式 [Head First设计模式]山西面馆中的设计模式— ...
随机推荐
-
2016年6月25日 星期六 --出埃及记 Exodus 14:22
2016年6月25日 星期六 --出埃及记 Exodus 14:22 and the Israelites went through the sea on dry ground, with a wal ...
-
ZOJ 1113 u Calculate e
原题链接 题目大意:迭代求自然常数e. 解法:没什么好说的,注意数据类型和输出格式. 参考代码: #include<stdio.h> #include<math.h> int ...
-
mysql四种事务隔离级的说明
·未提交读(Read Uncommitted):允许脏读,也就是可能读取到其他会话中未提交事务修改的数据 ·提交读(Read Committed):只能读取到已经提交的数据.Oracle等多数数据库默 ...
-
自己动手写CPU之第五阶段(3)——MIPS指令集中的逻辑、移位与空指令
将陆续上传本人写的新书<自己动手写CPU>(尚未出版),今天是第17篇.我尽量每周四篇 5.4 逻辑.移位操作与空指令说明 MIPS32指令集架构中定义的逻辑操作指令有8条:and.and ...
-
expect 交互 之双引号较长变量
交互双引号较长变量 #!/bin/bash RemoteUser=xuesong12 Ip=192.168.1.2 RemotePasswd=xuesong Cmd="/bin/echo ...
-
批量导入数据到mssql数据库的
概述 批量导入数据到数据库中,我们有好几种方式. 从一个数据表里生成数据脚本,到另一个数据库里执行脚本 从EXCEL里导入数据 上面两种方式,导入的数据都会生成大量的日志.如果批量导入5W条数据到数据 ...
-
20165333 2017-2018-2《Java程序设计》课程总结
一.每周作业链接汇总 1.预备作业一:我期望的师生关系 简要内容: 印象深刻的老师 我期望的师生关系 关于JAVA学习 2.预备作业二:学习基础和C语言学习基础 简要内容: 技能学习 C语言学习 关于 ...
-
django 常用命令 详解
check compilemessages createcachetable dbshell diffsettings dumpdata flush ...
-
重写(overwrite)、重载(overload)和覆盖(override)三者之间的区别
覆盖:子类继承了父类的同名无参函数.当子类从父类继承了一个无参函数,而又定义了一个同样的无参函数,则子类定义的方法覆盖父类的方法,称为覆盖. 重载:子类继承了父类的同名有参函数.当子类继承了父类的一个 ...
-
js删除数组中重复的元素
1.方法一 将数组逐个搬到另一个数组中,当遇到重复元素时,不移动,若元素不重复则移动到新数组中 function unique(arr){ var len = arr.length; var resu ...