当前位置:网站首页>[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
边栏推荐
- 【HCSD大咖直播】亲授大厂面试秘诀-简要笔记
- 【知识小结】PHP使用svn笔记总结
- Xcode Revoke certificate
- Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()
- 95. (cesium chapter) cesium dynamic monomer-3d building (building)
- OpenGL personal notes
- 修改配置文件后tidb无法启动
- Laravel constructor and middleware execution order
- 深度监听 数组深度监听 watch
- What is the difference between IP address and physical address
猜你喜欢

Logback日志框架第三方jar包 免费获取

爬虫(17) - 面试(2) | 爬虫面试题库

Unity3d click events added to 3D objects in the scene

Vs tool word highlight with margin

Record the migration process of a project

Odoo integrated plausible embedded code monitoring platform

【C 语言】 题集 of Ⅹ

Continuous creation depends on it!

PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()

Description of vs common shortcut keys
随机推荐
three. JS create cool snow effect
统计学习方法——感知机
You Yuxi, coming!
深度监听 数组深度监听 watch
模仿企业微信会议室选择
Xcode Revoke certificate
IP地址和物理地址有什么区别
How can laravel get the public path
爬虫(17) - 面试(2) | 爬虫面试题库
【C 语言】 题集 of Ⅹ
Three. JS series (1): API structure diagram-1
Laravel changed the session from file saving to database saving
01tire+ chain forward star +dfs+ greedy exercise one
Odoo集成Plausible埋码监控平台
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
谈谈 SAP iRPA Studio 创建的本地项目的云端部署问题
23. 合并K个升序链表-c语言
Power of leetcode-231-2
C语言进阶——函数指针
修改配置文件后tidb无法启动