当前位置:网站首页>[designmode] template method pattern
[designmode] template method pattern
2022-07-07 16:36:00 【weixin_ forty-three million two hundred and twenty-four thousan】
Basic introduction
Template method pattern (Template Method Pattern), Also called template mode (Template Pattern),z In an abstract class, the template that defines the method to execute it is exposed . Its subclass can override method implementation as needed , But the call will take place in the way defined in the abstract class .
In short , Template method pattern Defines the skeleton of an algorithm in an operation , Instead, defer some steps to subclasses , So that the subclass can not change the structure of an algorithm , You can redefine some specific steps of the algorithm
This type of design pattern belongs to behavioral pattern .
1. Problems in soybean milk production
Write procedures for making soybean milk , The explanation is as follows :
The process of making soybean milk Material selection —> Add ingredients —> soak —> Break it in the soymilk machine
By adding different ingredients , You can make soymilk with different flavors
Material selection 、 Soaking and smashing in a soymilk machine are the same for every flavor of soymilk
Please use Template method pattern complete ( explain : Because the template method pattern , Relatively simple , It's easy to come up with this plan , So use it directly , No longer use the traditional scheme to lead out the template method pattern )
2. Basic introduction to template method pattern
Basic introduction
Template method pattern (Template Method Pattern), Also called template mode (Template Pattern),z In an abstract class, the template that defines the method to execute it is exposed . Its subclass can override method implementation as needed , But the call will take place in the way defined in the abstract class .
In short , Template method pattern Defines the skeleton of an algorithm in an operation , Instead, defer some steps to subclasses , So that subclasses can not
边栏推荐
- 数据中台落地实施之法
- logback.xml配置不同级别日志,设置彩色输出
- 如何快速检查钢网开口面积比是否符合 IPC7525
- Opportunity interview experience summary
- IP地址和物理地址有什么区别
- Xcode Revoke certificate
- 【知识小结】PHP使用svn笔记总结
- Shandong old age Expo, 2022 China smart elderly care exhibition, smart elderly care and aging technology exhibition
- Prometheus API deletes all data of a specified job
- You Yuxi, coming!
猜你喜欢
pycharm 终端部启用虚拟环境
Three. JS series (1): API structure diagram-1
平衡二叉树(AVL)
Unity3d click events added to 3D objects in the scene
【Vulnhub靶场】THALES:1
Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
使用JSON.stringify()去实现深拷贝,要小心哦,可能有巨坑
Xcode Revoke certificate
【DesignMode】代理模式(proxy pattern)
随机推荐
three. JS create cool snow effect
47_ Contour lookup in opencv cv:: findcontours()
PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
[hcsd celebrity live broadcast] teach the interview tips of big companies in person - brief notes
Markdown formula editing tutorial
华东师大团队提出,具有DNA调控电路的卷积神经网络的系统分子实现
偶然升职的内心独白
爬虫(17) - 面试(2) | 爬虫面试题库
iptables只允许指定ip地址访问指定端口
95. (cesium chapter) cesium dynamic monomer-3d building (building)
Opencv personal notes
logback.xml配置不同级别日志,设置彩色输出
Xcode Revoke certificate
【DesignMode】模板方法模式(Template method pattern)
分类模型评价标准(performance measure)
What is the difference between IP address and physical address
3000 words speak through HTTP cache
laravel 是怎么做到运行 composer dump-autoload 不清空 classmap 映射关系的呢?
应用程序和matlab的通信方式
记一次项目的迁移过程