当前位置:网站首页>[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
边栏推荐
- Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
- Personal notes of graphics (4)
- What about the pointer in neural network C language
- [C language] question set of X
- IP地址和物理地址有什么区别
- Talk about the cloud deployment of local projects created by SAP IRPA studio
- 网关Gateway的介绍与使用
- Cesium (4): the reason why gltf model is very dark after loading
- Laravel5.1 路由 -路由分组
- 【DesignMode】外观模式 (facade patterns)
猜你喜欢
随机推荐
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
Continuous creation depends on it!
二叉搜索树(基操篇)
作为Android开发程序员,android高级面试
How to determine whether the checkbox in JS is selected
Record the migration process of a project
Vs tool word highlight with margin
Communication mode between application program and MATLAB
Usage of config in laravel
Rongyun won the 2022 China Xinchuang digital office portal excellence product award!
Laravel5.1 路由 -路由分组
Opportunity interview experience summary
MySQL数据库基本操作-DQL-基本查询
"The" "PIP" "entry cannot be recognized as the name of a cmdlet, function, script file, or runnable program."
What is the difference between IP address and physical address
Talk about the cloud deployment of local projects created by SAP IRPA studio
统计学习方法——感知机
Unity3d click events added to 3D objects in the scene
C语言进阶——函数指针
Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench






![[Android -- data storage] use SQLite to store data](/img/f6/a4930276b3da25aad3ab1ae6f1cf49.png)


