当前位置:网站首页>[designmode] Prototype Pattern
[designmode] Prototype Pattern
2022-07-02 03:28:00 【weixin_ forty-three million two hundred and twenty-four thousan】
Basic introduction :
Archetypal model (Prototype Pattern ) Refer to : Using prototype instances to specify the kind of objects to create , And by copying these prototypes , Create a new object
Prototype pattern is a kind of creative design pattern , Allow one object to create another customizable object , No need to know how to create details
How it works : By passing a prototype object to the object to launch the creation , The object to be created is implemented by requesting prototype objects to copy themselves , namely object .clone()
1. The problem of sheep cloning
Now there is a sheep tom, The name is : tom, Age is :1, The color is : white , Please write a program to create and tom sheep The attributes are exactly the same 10
A sheep .
2. The traditional way to solve the problem of sheep cloning
Class diagram :
Code :
package com.mumu.prototype;
public class
边栏推荐
- Aaaaaaaaaaaa
- spark调优
- NLog使用
- Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]
- SAML2.0 笔记(一)
- venn图取交集
- 焱融看 | 混合云时代下,如何制定多云策略
- Kubernetes cluster storageclass persistent storage resource core concept and use
- This article describes the step-by-step process of starting the NFT platform project
- Large screen visualization from bronze to the advanced king, you only need a "component reuse"!
猜你喜欢
QT environment generates dump to solve abnormal crash
What do you know about stock selling skills and principles
Verilog timing control
Knowing things by learning | self supervised learning helps improve the effect of content risk control
JS introduction < 1 >
NLog使用
MySQL advanced (Advanced) SQL statement (II)
C shallow copy and deep copy
Find duplicates [Abstract binary / fast and slow pointer / binary enumeration]
Design details of SAP e-commerce cloud footernavigationcomponent
随机推荐
MySQL connection query and subquery
West digital decided to raise the price of flash memory products immediately after the factory was polluted by materials
Global and Chinese markets for ultrasonic probe disinfection systems 2022-2028: Research Report on technology, participants, trends, market size and share
How to establish its own NFT market platform in 2022
一天上手Aurora 8B/10B IP核(5)----从Framing接口的官方例程学起
MySQL index, transaction and storage engine
MySQL advanced (Advanced) SQL statement (II)
Sentry experience and architecture, a fledgling monitoring product with a market value of $100million
Global and Chinese market of handheld ultrasonic scanners 2022-2028: Research Report on technology, participants, trends, market size and share
Global and Chinese markets for welding equipment and consumables 2022-2028: Research Report on technology, participants, trends, market size and share
"Analysis of 43 cases of MATLAB neural network": Chapter 42 parallel operation and neural network - parallel neural network operation based on cpu/gpu
< job search> process and signal
MySQL之账号管理
C#聯合halcon脫離halcon環境以及各種報錯解决經曆
Form custom verification rules
What is hybrid web containers for SAP ui5
《MATLAB 神经网络43个案例分析》:第41章 定制神经网络的实现——神经网络的个性化建模与仿真
/silicosis/geo/GSE184854_scRNA-seq_mouse_lung_ccr2/GSE184854_RAW/GSM5598265_matrix_inflection_demult
Kubernetes cluster storageclass persistent storage resource core concept and use
【DesignMode】建造者模式(Builder model)