Notes
Search
⌃K
Notes
Search
⌃K
Introduce
Go
Grammar
System Library
Concurrency in Go
The Go Memory Model
Code Snippet
Rust
The Rust Programming Language
Rust by Example
JAVA
Preface
Grammar
Class Libraries
Concurrency
JVM
Web Container
Spring
Tuning
Computer Science
Computer Organization
Algorithm
Network Protocol
Operating System
Design Patterns
UML
OOP
Principle
Refactoring & Specification
Creational
Singleton
Factory
Builder
Prototype
Structural
Behavioral
Distributed System
database
InfluxDB
MySQL
Redis
Elasticsearch
HBase
Kafka
ZooKeeper
Reading
RocketMQ
演说之禅
So Good They Can't Ignore You
学会提问
Lecture
Other
v2ray
Kubernetes
Git
Maven
Anaconda And Conda
Fuck! Shit!
Open source contribution
Powered By
GitBook
Prototype
如果对象的创建成本比较大,而同一个类的不同对象之间差别不大(大部分数据相同),我们可以利用已有对象(原型)进行复制来创建新对象,以节约创建时间。
使用原型来复制新对象时,注意深拷贝和浅拷贝的区别。
对象创建成本比较大的场景:
对象中的数据需要经过复杂计算才能得到,比如排序、计算 hash 值
需要从 RPC、网络、数据库、文件系统等慢 IO 中读取。
Previous
Builder
Next
Structural
Last modified
3yr ago