当前位置:网站首页>Simple factory factory method Abstract Factory
Simple factory factory method Abstract Factory
2022-07-25 06:27:00 【Little wolf】
Simple factory : Factories can create the same series of products , The interface of the product is consistent , But the factory must judge which product to create according to the parameters ( Simple factories have no subclasses , Generally speaking, create instances directly in the factory through enumeration ).
such as : The noodle shop has onion noodles , Beef noodles , egg noodle ... What kind of noodles would you like , It depends on your taste .
Factory method : There can be a variety of factories , Factories have common interfaces , A factory can produce only one product , Compared with a simple factory , The factory method does not require judgment , Reduced coupling ( Define the interface for creating objects , Instantiation is the responsibility of subclasses , And only one kind can be instantiated )
such as : Boss Yang has three stores : Those who only sell steamed buns Steamed bun shop , Water that only sells water , Coffee only The coffee shop
Abstract factory : Can produce multiple series of products ( involves The concept of product family : In different product grades , A family of products with related functions )( Define the interface for creating objects , Define all products , Instantiation is the responsibility of subclasses , Whether a product can be created depends entirely on it )
such as : McDonald's boss : Coke system products , Hamburger series products , There are three kinds of products, large, medium and small
The biggest difference between simple factory and factory method is : Factory methods do not make logical judgments in factory classes , The system can provide different factories for different product categories , Different factories produce different products .( The factory method is convenient for adding new products )
The biggest difference between factory method and abstract factory is : Abstract factories create objects that are more complex , The intention of abstract factory is : Provide an interface , You can create product objects in multiple product families , such as NSNumber Medium NSCFNumber and NSCFBoolean.( Because the creation of products is determined by abstract classes , So it is inconvenient to add new products )
边栏推荐
- MFC IniFile Unicode mode reading method
- This is how the permission system is designed, yyds
- [Luogu p6629] string (runs) (tree array)
- JS 获取鼠标选中的文字并处于选中状态
- JZ7 重建二叉树
- C language -c51 compilation warning "* * * warning l1: unresolved external symbol" and extern
- 函数模板学习记录
- 阻塞队列分析
- Machine learning keras fitting sine function
- Seekbar attribute reference
猜你喜欢
This is how the permission system is designed, yyds

NFT: how to improve rentable NFT (erc-4907)

Netease game Flink SQL platform practice

【Node】服务端口被占用Error: listen EADDRINUSE: address already in use :::9000-如何关闭node启动的端口
![[sword finger offer] analog implementation ATOI](/img/01/76a3b1fcc6403368a363146d553777.png)
[sword finger offer] analog implementation ATOI

SAP FICO 第三节 BDC和LTMC导入S4财务科目

Blocking Queue Analysis
![[C language] document processing and operation](/img/d7/3d34401f78399dcd6d571bc0bc84bf.png)
[C language] document processing and operation

New developments in Data Governance: what is the impact of the EU's Data Governance Research Report on China

Req.body in node.express is always undefind
随机推荐
[node] the service port is occupied error: listen eaddinuse: address already in use::: 9000- how to close the port started by node
Scientific computing library numpy Foundation & Improvement (Understanding + explanation of important functions)
VBS common built-in functions (2)
Qt 5界面修改无效的问题解决QtDesigner修改之后无效的解决办法
[datawhale202207] reinforcement learning: strategy gradient and near end strategy optimization
node.express中req.body总是undefind解决
Clear wechat applet and wechat H5 cache
Req.body in node.express is always undefind
【C】 Program environment and pretreatment
VSCode 如何开启多个终端?如何横向显示?
How to troubleshoot the problem of too many inodes
JS gets the text selected by the mouse and is in the selected state
Brief tutorial of vbs script syntax (1)
Typedef usage and template
C # read Beckhoff variable
This is how the permission system is designed, yyds
Mlx90640 infrared thermal imager temperature measurement module development notes (I)
[ultra detailed diagram] FPN + mask RCNN
【transformer】DeiT
Netease game Flink SQL platform practice