惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Recorded Future
Recorded Future
Microsoft Security Blog
Microsoft Security Blog
Recent Commits to openclaw:main
Recent Commits to openclaw:main
The Register - Security
The Register - Security
The GitHub Blog
The GitHub Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
量子位
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
Stack Overflow Blog
Stack Overflow Blog
H
Help Net Security
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
B
Blog RSS Feed
小众软件
小众软件
博客园 - 叶小钗
H
Hackread – Cybersecurity News, Data Breaches, AI and More
博客园 - 聂微东
博客园_首页
B
Blog
雷峰网
雷峰网
S
SegmentFault 最新的问题
N
Netflix TechBlog - Medium
D
Docker
博客园 - 司徒正美
博客园 - 【当耐特】
大猫的无限游戏
大猫的无限游戏
博客园 - Franky
MongoDB | Blog
MongoDB | Blog
U
Unit 42
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
腾讯CDC
F
Fortinet All Blogs
aimingoo的专栏
aimingoo的专栏
Martin Fowler
Martin Fowler
Jina AI
Jina AI
WordPress大学
WordPress大学
D
DataBreaches.Net
V
V2EX
V
Visual Studio Blog
Know Your Adversary
Know Your Adversary
P
Privacy & Cybersecurity Law Blog
F
Full Disclosure
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
The Hacker News
The Hacker News
Security Archives - TechRepublic
Security Archives - TechRepublic
IT之家
IT之家
P
Privacy International News Feed

博客园 - 心雨无痕

升级openssl和openssh linux配置LVM 杂七杂八 .net程序包含webbrowser插件时遇到的各种问题 mysql连接远程服务器很慢的解决方法 centos安装php需要注意的问题 centos配置nfs杂七杂八 iptables配置网络端口转发 桥接模式 适配器模式 单例模式 工厂方法模式 简单工厂模式 建造者模式 ActionScript中Object和Dictionary的区别 FlashBuilder4.5破解方法 抽象工厂模式 设计模式浅见 了解下常见的开源协议
原型模式
心雨无痕 · 2012-06-27 · via 博客园 - 心雨无痕

原型模式用于复制对象,抽象产品类定义复制自身的方法,实体产品类继承抽象产品类并实际实现复制方法,在客户使用时直接调用该复制方法即可。

为什么要使用这个模式

当有产品经常需要进行复制,而且该产品的复制方法比较复杂而且很可能非常多变,更加可能的是客户需要使用许多种该类产品,这种情况下就非常适合用原型模式。

原型模式概述

原型模式核心包括2个角色:

1. 抽象产品类IC(接口IA),该类定义了复制自身的方法

2. 实体产品类,实现上述接口A或继承抽象类IC,实际实现复制方法

客户一般使用方法(假设实体产品类为PA和PB,IA定义的接口方法为Clone):

IA a = new PA();
IA b = new PB();
IA c = a.Clone();
IA d = b.Clone();