当前位置:网站首页>Difference between factory mode and strategy mode
Difference between factory mode and strategy mode
2022-06-29 09:19:00 【amateur12】
Same as :
On the pattern structure , The two are very similar

different :
1. Factory is a creation mode , Its purpose is to create objects , According to the transmission parameters , Create different objects , The method of using an object after it is created
Strategy is a behavioral model , Its function is to let an object choose a behavior among many behaviors
2. Create a focus object , A focus behavior encapsulation
3. The factory parameter is a type , Policy parameter transfer is a new object
summary :
What the factory model can do , Strategic models can do . What the strategic model can do , Factory mode can also do , It just gets troublesome . because , Factory mode is mainly the instantiation object of the returned interface implementation class , Then call the method of the object , The policy pattern object is created when the policy pattern is instantiated , We You can freely splice and rewrite methods in the policy pattern , The factory model is regardless of the splicing of these methods , He only focuses on the final result , Don't pay attention to the process , Only instantiated objects are returned at a time , Then call the object's methods again , The strategic model focuses on the process .
Applicable scenarios :
Factory pattern is a creative design pattern , It takes orders , Create the required instance ; The main solution is the unified distribution of resources , Independent creation of objects , Let the creation of objects have nothing to do with specific customers . Main application in multi database selection , Class library file loading, etc .
The policy mode is used to solve the problem of policy switching and extension , More succinctly, define the policy family , Separately encapsulated , So that they can replace each other , The strategy pattern makes the strategy change independent of the customers who use the strategy .
Add :
Policy mode and Microservices :
The policy pattern is very similar to microservices , For example, we write 3 Interface , Eating is a micro service , Running is a micro service , Dressing is a micro service . The purpose of the strategy model is to connect various methods , Reach a new way , The purpose of microservices is to prevent multiple calls of services , Reduce code coupling , So it seems that the policy mode is similar to the microservice
边栏推荐
- 微信小程序项目:微信小程序页面布局
- H5软键盘问题
- (转)MySQL: ERROR 1071 (42000): Specified key was too long; max key length is 767 bytes
- Yolo nano: a highly compact one look convolutional neural network for target detection
- Member inner class, static inner class, local inner class
- GPU训练云平台记录
- Verilog shift operator
- Wechat applet jump to official account image and text content
- 实例报错IOPub data rate exceeded
- Augfpn: amélioration de l'apprentissage des caractéristiques à plusieurs échelles pour la détection des cibles
猜你喜欢

First electric shock, so you are such a dragon lizard community | dragon lizard developer said that issue 8
![[target detection] | indicator a probabilistic challenge for object detection](/img/82/7b830d44bed7b1509cb0cdfed88e3e.png)
[target detection] | indicator a probabilistic challenge for object detection

【目标检测】|指标 A probabilistic challenge for object detection

ActiveMQ message component publish subscribe redelivery message redelivery

Let you know today that the passing rate of the PMP Exam is 97%, is it believable

YOLACT实时实例分割

train_on_batch保存一下loss函数变化的图像

在 golang 中是如何对 epoll 进行封装的?

Let's make a summary

SSD改进CFENet
随机推荐
手写VirtualDOM
Open3d hidden point removal
微信小程序项目:微信小程序页面布局
Detailed version of two-stage target detection principle
PointNet/Pointnet++训练及测试
微信小程序打开文件流
微信小程序最新canvas2d手写签名
SSD改進CFENet
图片格式-webp
pytorch学习总结—运算的内存开销
SSD Improvement cfenet
Open3D 最远点采样(FPS)
【数据集】|标注的bbox影响 Can we trust bounding box annotations for object detection
pytorch总结学习系列-操作
Wechat applet project: tab navigation bar
Let you know today that the passing rate of the PMP Exam is 97%, is it believable
Which securities company is good for opening a mobile account? Is it safe to open an account online?
Yolo nano: a highly compact one look convolutional neural network for target detection
ServerApp.iopub
train_on_batch保存一下loss函数变化的图像