当前位置:网站首页>[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
边栏推荐
- 01tire+ chain forward star +dfs+ greedy exercise one
- Personal notes of graphics (1)
- Balanced binary tree (AVL)
- 47_ Contour lookup in opencv cv:: findcontours()
- 预测——灰色预测
- How does laravel run composer dump autoload without emptying the classmap mapping relationship?
- 23. 合并K个升序链表-c语言
- Continuous creation depends on it!
- 删除 console 语句引发的惨案
- What else can an ordinary person do besides working in a factory to make money?
猜你喜欢

Description of vs common shortcut keys

【医学分割】attention-unet

Opencv personal notes

Tragedy caused by deleting the console statement

Cesium(3):ThirdParty/zip. js

Vs2019 configuration matrix library eigen

Odoo集成Plausible埋码监控平台

Leetcode-231-2的幂

Vs tool word highlight with margin

Talk about the cloud deployment of local projects created by SAP IRPA studio
随机推荐
2022 the 4th China (Jinan) International Smart elderly care industry exhibition, Shandong old age Expo
The difference and working principle between compiler and interpreter
[C language] question set of X
spark调优(三):持久化减少二次查询
Odoo集成Plausible埋码监控平台
01tire+链式前向星+dfs+贪心练习题.1
Laravel constructor and middleware execution order
Description of vs common shortcut keys
分类模型评价标准(performance measure)
AutoLISP series (1): function function 1
数据中台落地实施之法
记一次项目的迁移过程
47_Opencv中的轮廓查找 cv::findContours()
torch.numel作用
使用JSON.stringify()去实现深拷贝,要小心哦,可能有巨坑
121. The best time to buy and sell stocks
Balanced binary tree (AVL)
URL和URI的关系
Laravel post shows an exception when submitting data
Common training data set formats for target tracking