当前位置:网站首页>[designmode] factory pattern
[designmode] factory pattern
2022-06-30 23:44:00 【weixin_ forty-three million two hundred and twenty-four thousan】
1. Simple factory model
The simple factory pattern is a creation pattern , It's a kind of factory model . The simple factory pattern is that a factory object determines which product to create
Class . The simple factory pattern is the simplest and most practical pattern in the family of factory patternsSimple factory model : Defines a class for creating objects , This class encapsulates the behavior of the instantiated object ( Code )
In software development , When we're going to use a lot to create a certain 、 When a class or a batch of objects , It will use the factory mode .
1.1 Look at a specific need
Look at a pizza project : To facilitate the expansion of pizza varieties , Be easy to maintain
There are many kinds of pizza ( such as GreekPizz、CheesePizz etc. )
Pizza is made of prepare,bake, cut, box
Complete the pizza order function .
1.2 Use the traditional way to complete
Class diagram :

Code :
//public class OrderPizza {
// Constructors
// public OrderPizza() {
// Pizza pizza = null;
<边栏推荐
- Redis' transaction and locking mechanism
- 1. crawler's beautifulsoup parsing library & online parsing image verification code
- JMeter cross thread parameter association requires no script
- LVM snapshot: backup based on LVM snapshot
- Esp8266 becomes client and server
- Ride: get picture Base64
- Lombok
- 76页智慧物流园区综合解决方案2022(附下载)
- Reason why wechat payment wxpaypubhelper V3 callback XML is empty
- Fh6908a negative pole turn off synchronous rectification analog low voltage drop diode control IC chip tsot23-6 ultra low power rectifier 1W power consumption < 100ua static replacement mp6908
猜你喜欢
![Cesiumjs 2022 ^ source code interpretation [6] - new architecture of modelempirical](/img/ce/519778cd731f814ad111d1e37abd10.png)
Cesiumjs 2022 ^ source code interpretation [6] - new architecture of modelempirical

76 page comprehensive solution 2022 for smart Logistics Park (download attached)

让企业数字化砸锅和IT主管背锅的软件供应链安全风险指北

Software supply chain security risk pointing North for enterprise digitalization and it executives

Two way data binding in wechat applet

206页上海BIM技术应用与发展报告2021

Kubevela 1.4: make application delivery safer, easier to use, and more transparent

Netease cloud sign in lottery? That year I could sign in for 365 days. No? Look.

MaxPool2d详解--在数组和图像中的应用

conv2d详解--在数组和图像中的使用
随机推荐
206页上海BIM技术应用与发展报告2021
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
5G智慧建筑解决方案2021
Redis - 01 cache: how to use read cache to improve system performance?
shell 同时执行多任务下载视频
Redis' cache penetration, cache breakdown and cache avalanche
Schéma de transition asynchrone - générateur
Two way data binding in wechat applet
需求评审,测试人员应该发挥怎样的价值?两分钟让你不再懵逼
CesiumJS 2022^ 源码解读[6] - 三维模型(ModelExperimental)新架构
Is it safe to buy funds on the compass?
Redis - 01 缓存:如何利用读缓存提高系统性能?
Why should VR panoramic shooting join us? Leverage resources to achieve win-win results
Cesiumjs 2022 ^ source code interpretation [6] - new architecture of modelempirical
How do I open a stock account on my mobile phone? In addition, is it safe to open a mobile account?
基金客户和销售机构
CentOS 6.3 x64 PHP 5.2.6 扩展安装OpenSSL出错的解决方法
[leetcode] [SQL] notes
Don't worry about whether you can be a coder if you don't learn English well. Learn it first
未来十年世界数字化与机器智能展望