当前位置:网站首页>【DesignMode】适配器模式(adapter pattern)
【DesignMode】适配器模式(adapter pattern)
2022-07-05 23:57:00 【weixin_43224306】
- 基本介绍
适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示,主的目的是兼容性,让原本因接口不匹配不能一起工作的两个类可以协同工作。其别名为包装器(Wrapper)
适配器模式属于结构型模式
主要分为三类:类适配器模式、对象适配器模式、接口适配器模式
1. 现实生活中的适配器例子
泰国插座用的是两孔的(欧标),可以买个多功能转换插头 (适配器) ,这样就可以使用了。
2. 基本介绍
适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示,主的目的是兼容性,让原本因接口不匹配不能一起工作的两个类可以协同工作。其别名为包装器(Wrapper)
适配器模式属于结构型模式
主要分为三类:类适配器模式、对象适配器模式、接口适配器模式
3. 工作原理
适配器模式:将一个类的接口转换成另一种接口.让原本接口不兼容的类可以兼容
从用户的角度看不到被适配者,是解耦的
用户调用适配器转化出来的目标接口方法,适配器再调用被适配者的相关接口方法
用户收到反馈结果,感觉只是和目标接口交互,如图
边栏推荐
- Choose to pay tribute to the spirit behind continuous struggle -- Dialogue will values [Issue 4]
- 教你在HbuilderX上使用模拟器运行uni-app,良心教学!!!
- What are the functions of Yunna fixed assets management system?
- Problems encountered in the database
- openssl-1.0.2k版本升级openssl-1.1.1p
- 选择致敬持续奋斗背后的精神——对话威尔价值观【第四期】
- 21. PWM application programming
- 2022.7.5-----leetcode.729
- Open3D 点云随机添加噪声
- 行列式学习笔记(一)
猜你喜欢

Part III Verilog enterprise real topic of "Niuke brush Verilog"
![[online chat] the original wechat applet can also reply to Facebook homepage messages!](/img/d2/1fd4de4bfd433ed397c236ddb97a66.png)
[online chat] the original wechat applet can also reply to Facebook homepage messages!

Permission problem: source bash_ profile permission denied

Spreadjs 15.1 CN and spreadjs 15.1 en

Biased sample variance, unbiased sample variance

Rsync remote synchronization

XML configuration file (DTD detailed explanation)

CAS and synchronized knowledge
![[binary search tree] add, delete, modify and query function code implementation](/img/38/810a83575c56f17a7a0ed428a2e02e.png)
[binary search tree] add, delete, modify and query function code implementation

Open source CRM customer relationship system management system source code, free sharing
随机推荐
Problem solving win10 quickly open ipynb file
Effet Doppler (déplacement de fréquence Doppler)
20220703 week race: number of people who know the secret - dynamic rules (problem solution)
Breadth first search open turntable lock
5. Logistic regression
C # input how many cards are there in each of the four colors.
权限问题:source .bash_profile permission denied
[day39 literature extensive reading] a Bayesian perspective on magnetic estimation
Biased sample variance, unbiased sample variance
GFS distributed file system
多普勒效应(多普勒频移)
Bao Yan notebook IV software engineering and calculation volume II (Chapter 8-12)
VBA fast switching sheet
PV static creation and dynamic creation
Configuring OSPF load sharing for Huawei devices
Zhongjun group launched electronic contracts to accelerate the digital development of real estate enterprises
Qt QPushButton详解
Laser slam learning record
Asynchronous task Whenall timeout - Async task WhenAll with timeout
FFmpeg学习——核心模块