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

推荐订阅源

S
Schneier on Security
A
Arctic Wolf
S
Security Affairs
O
OpenAI News
SecWiki News
SecWiki News
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
T
Threat Research - Cisco Blogs
Hacker News: Ask HN
Hacker News: Ask HN
N
News | PayPal Newsroom
Google Online Security Blog
Google Online Security Blog
C
Cisco Blogs
The Hacker News
The Hacker News
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy International News Feed
V
Vulnerabilities – Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
T
Tenable Blog
T
The Exploit Database - CXSecurity.com
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Spread Privacy
Spread Privacy
人人都是产品经理
人人都是产品经理
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V2EX - 技术
V2EX - 技术
L
LINUX DO - 最新话题
The GitHub Blog
The GitHub Blog
博客园 - 三生石上(FineUI控件)
T
The Blog of Author Tim Ferriss
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
The Cloudflare Blog
N
News and Events Feed by Topic
量子位
Google DeepMind News
Google DeepMind News
Application and Cybersecurity Blog
Application and Cybersecurity Blog
L
LINUX DO - 热门话题
P
Palo Alto Networks Blog
Stack Overflow Blog
Stack Overflow Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Attack and Defense Labs
Attack and Defense Labs
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Hacker News - Newest:
Hacker News - Newest: "LLM"
Apple Machine Learning Research
Apple Machine Learning Research
The Register - Security
The Register - Security
Microsoft Security Blog
Microsoft Security Blog
Know Your Adversary
Know Your Adversary
Webroot Blog
Webroot Blog

博客园 - Cameo

解决VSTO项目重定向到.NET Framework 4的编译和运行时错误 Excel 应用程序如何创建数据透视表 值类型与引用类型 Visual studio tools for office体系结构 C#类型转换 VSTO开发团队成立 15. Command 命令(行为型模式) 14. Template Method模板方法(行为型模式) 13. Proxy代理(结构型模式) 12. Flyweight享元(结构型模式) 11. Facade外观[门面模式](结构型模式) 10. Decorator 装饰(结构型模式) 9. Composite 组合(结构型模式) 8. Bridge 桥接(结构型模式) 7. Adapter 适配器(结构型模式) 5. Factory Method 工厂方法(创建型模式的基础) 4.Builder 建造者(生成器)(创建型模式) 书籍收藏 3. Abstract Factory 抽象工厂(创建型模式)
6. Prototype 原型(创建型模式)
Cameo · 2008-06-10 · via 博客园 - Cameo

依赖关系的倒置
抽象不应该依赖于实现细节,实现细节应该依赖于抽象
[原因是抽象变化的频率(速率)慢,细节变化的频率快]
 – 抽象A直接依赖于实现细节b             –抽象A依赖于抽象B,实现细节b依赖于抽象B
 

 动机(Motivation)
    在软件系统中,经常面临着“某些结构复杂的对象”的创建工作;由于需求的变化,这些对象经常面临着剧烈的变化,但是它们却拥有比较稳定一致的接口
    如何应对这种变化?如何向“客户程序(使用这些对象的程序)”隔离出“这些易变对象” ,从而使得“赖这些易变对象的客户程序不随着需求改变而改变

意图(Intent)
    使用原型实例指定创建对象的种类,然后通过拷贝这些原型来创建新的对象。
                                                                                                    ——《设计模式》GoF
结构(Structure)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Propotype_Pattern
{
    
class Program
    
{
        
Absctract Prototype | 原型抽象

        
CreatePrototypeB | 具体产品B

        
CreatePrototypeA | 具体产品A

        
Client Application | 客户端程序
    }

}

Prototype模式的几个要点
    • Prototype模式同样用于隔离类对象的使用者和具体类型(易变类)之间的耦合关系,它同样要求这些“易变类”拥有“稳定的接口”
    • Prototype模式对于“如何创建易变类的实体对象”采用“原型克隆”的方法来做,它使得我们可以非常灵活地动态创建“拥有某些稳定接口”的新对象——所需工作仅仅是注册一个新类的对象(即原型),然后在任何需要的地方不断地Clone
    • Prototype模式中的Clone方法可以利用.NET中的Object类的MemberwiseClone()方法或者序列化来实现深拷贝

有关创建性模式的讨论
    • Singleton模式解决的是实体对象个数的问题。除了Singleton之外,其他创建型模式解决的都是new所带来的耦合关系
    • Factory Method, Abstract Factory, Builder都需要一个额外的工厂类来负责实例化“易变对象”,而Prototype则是通过原型(一个特殊的工厂类)来克隆“易变对象”
    • 如果遇到“易变类”,起初的设计通常从FactoryMethod开始,当遇到更多的复杂变化时,再考虑重构为其他三种工厂模式( Abstract Factory,Builder , Prototype )。