当前位置:网站首页>[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;
<边栏推荐
- Inventory the six second level capabilities of Huawei cloud gaussdb (for redis)
- Shell multitasking to download video at the same time
- Is it safe to buy funds on the compass?
- In depth understanding of jetpack compose kernel: slottable system
- What does project management really manage?
- During telecommuting, the project team punched in the wechat group | solicited papers from the community
- Sm2246en+ SanDisk 15131
- C language array interception, C string by array interception method (c/s)
- What value should testers play in requirements review? Two minutes will stop you from being stupid
- C /platform:anycpu32bitpererrored can only be used with /t:exe, /t:winexe and /t:appcontainerexe
猜你喜欢

New trends of China's national tide development in 2022

HP 惠普笔记本电脑 禁用触摸板 在插入鼠标后

HP notebook disable touchpad after mouse is inserted

Introduction to machine learning compilation course learning notes lesson 2 tensor program abstraction

Analysis of 8253a register
![[fundamentals of wireless communication-13]: illustrated mobile communication technology and application development-1-overview](/img/1d/62e55f1b5445d7349ec383879f4275.png)
[fundamentals of wireless communication-13]: illustrated mobile communication technology and application development-1-overview

5G智慧建筑解决方案2021

Redis - 01 cache: how to use read cache to improve system performance?

shell 同时执行多任务下载视频

5g smart building solution 2021
随机推荐
"Paddle + camera" has become a "prefabricated dish" in the AI world, and it is easier to implement industrial AI quality inspection
Operation record of reinitialization instance of Dameng database
Is it safe to open a stock account of Huatai Securities online?
hot-fix、cherry-pick怎么提
JMeter cross thread parameter association requires no script
如何区分平台安全和网上炒作?网络投机有哪些止损技巧?
Online customer service chat system source code_ Beautiful and powerful golang kernel development_ Binary operation fool installation_ Attached construction tutorial
Qt笔记(七十四)之QLineEdit指定输入类型
Doker's container data volume
IFLYTEK active competition summary! (12)
Fund customer service
The girlfriend said: if you want to understand the three MySQL logs, I will let you heiheihei!
一次革命、两股力量、三大环节:《工业能效提升行动计划》背后的“减碳”路线图
Cesiumjs 2022 ^ source code interpretation [6] - new architecture of modelempirical
C /platform:anycpu32bitpererrored can only be used with /t:exe, /t:winexe and /t:appcontainerexe
[fundamentals of wireless communication-13]: illustrated mobile communication technology and application development-1-overview
2022-06-30:以下golang代码输出什么?A:0;B:2;C:运行错误。 package main import “fmt“ func main()
How to mention hot fix and cherry pick
在指南针上买基金安全吗?
conv2d详解--在数组和图像中的使用