当前位置:网站首页>【DesignMode】适配器模式(adapter pattern)
【DesignMode】适配器模式(adapter pattern)
2022-07-05 23:57:00 【weixin_43224306】
- 基本介绍
适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示,主的目的是兼容性,让原本因接口不匹配不能一起工作的两个类可以协同工作。其别名为包装器(Wrapper)
适配器模式属于结构型模式
主要分为三类:类适配器模式、对象适配器模式、接口适配器模式
1. 现实生活中的适配器例子
泰国插座用的是两孔的(欧标),可以买个多功能转换插头 (适配器) ,这样就可以使用了。
2. 基本介绍
适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示,主的目的是兼容性,让原本因接口不匹配不能一起工作的两个类可以协同工作。其别名为包装器(Wrapper)
适配器模式属于结构型模式
主要分为三类:类适配器模式、对象适配器模式、接口适配器模式
3. 工作原理
适配器模式:将一个类的接口转换成另一种接口.让原本接口不兼容的类可以兼容
从用户的角度看不到被适配者,是解耦的
用户调用适配器转化出来的目标接口方法,适配器再调用被适配者的相关接口方法
用户收到反馈结果,感觉只是和目标接口交互,如图
边栏推荐
- Chapter 16 oauth2authorizationrequestredirectwebfilter source code analysis
- Asynchronous task Whenall timeout - Async task WhenAll with timeout
- 硬件及接口学习总结
- MySQL之函数
- GD32F4xx uIP协议栈移植记录
- 15 MySQL-存储过程与函数
- 妙才周刊 - 8
- 权限问题:source .bash_profile permission denied
- Make a short video clip number of we media film and television. Where can I download the material?
- Russian Foreign Ministry: Japan and South Korea's participation in the NATO summit affects security and stability in Asia
猜你喜欢

21. PWM application programming

Bao Yan notebook IV software engineering and calculation volume II (Chapter 8-12)

激光slam学习记录

云呐|公司固定资产管理系统有哪些?

CAS and synchronized knowledge

Huawei equipment configuration ospf-bgp linkage

选择致敬持续奋斗背后的精神——对话威尔价值观【第四期】

Zhongjun group launched electronic contracts to accelerate the digital development of real estate enterprises

云呐|固定资产管理系统功能包括哪些?

Initialiser votre vecteur & initialisateur avec une liste Introduction à la Liste
随机推荐
The difference of time zone and the time library of go language
单商户V4.4,初心未变,实力依旧!
【luogu P3295】萌萌哒(并查集)(倍增)
Transport layer protocol ----- UDP protocol
转:未来,这样的组织才能扛住风险
Initialiser votre vecteur & initialisateur avec une liste Introduction à la Liste
Online yaml to CSV tool
What if the C disk is not enough? Let's see how I can clean up 25g of temp disk space after I haven't redone the system for 4 years?
What are the functions of Yunna fixed assets management system?
Biased sample variance, unbiased sample variance
[noi simulation] Anaid's tree (Mobius inversion, exponential generating function, Ehrlich sieve, virtual tree)
[binary search tree] add, delete, modify and query function code implementation
多普勒效應(多普勒頻移)
wx.getLocation(Object object)申请方法,最新版
C reflection and type
Spire Office 7.5.4 for NET
Redis high availability - master-slave replication, sentinel mode, cluster
QT -- thread
Mathematical model Lotka Volterra
【LeetCode】5. Valid palindrome