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

推荐订阅源

Forbes - Security
Forbes - Security
T
Tailwind CSS Blog
Hugging Face - Blog
Hugging Face - Blog
Blog — PlanetScale
Blog — PlanetScale
WordPress大学
WordPress大学
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
U
Unit 42
I
InfoQ
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Visual Studio Blog
B
Blog RSS Feed
Vercel News
Vercel News
F
Fortinet All Blogs
Know Your Adversary
Know Your Adversary
T
Troy Hunt's Blog
博客园 - 【当耐特】
MongoDB | Blog
MongoDB | Blog
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Jina AI
Jina AI
小众软件
小众软件
T
Threatpost
有赞技术团队
有赞技术团队
人人都是产品经理
人人都是产品经理
The Hacker News
The Hacker News
T
The Exploit Database - CXSecurity.com
C
CXSECURITY Database RSS Feed - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
Scott Helme
Scott Helme
B
Blog
腾讯CDC
Last Week in AI
Last Week in AI
P
Proofpoint News Feed
S
Schneier on Security
N
News and Events Feed by Topic
Microsoft Security Blog
Microsoft Security Blog
K
Kaspersky official blog
G
Google Developers Blog
T
Tor Project blog
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
Google Online Security Blog
Google Online Security Blog
Latest news
Latest news
Google DeepMind News
Google DeepMind News
MyScale Blog
MyScale Blog
罗磊的独立博客

博客园 - 心雨无痕

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

    抽象工厂的概念实现事实上就是接口和抽象类,用过Java、C++的人都了解这个概念,这里不多说了。

    为什么要用这个模式

    可以将具体的产品抽象化,使得具体的业务逻辑和产品概念分离。比如说写一个水果应用模块吧(有多种水果,比如[苹果]、[香蕉]、[桔子]),所有的水果都有2个方法,A()和B(),[苹果]、[香蕉]、[桔子]的这2个方法实现是不同的,甚至有可能是不同的程序员写的,对外部应用来讲,只需要传入一个水果对象并调用A和B两个方法,并不关心我传入的对象是什么水果,这种情况下,使用抽象工厂模式就可以对代码进行解耦,即定义一个接口或者抽象类[水果],[苹果]、[香蕉]、[桔子]类都实现这个接口或者继承这个抽象类。外部应用调用时只需要传入[水果]并调用方法即可,以后再有其他水果,直接添加新的类就可以了。