当前位置:网站首页>【DesignMode】适配器模式(adapter pattern)
【DesignMode】适配器模式(adapter pattern)
2022-07-05 23:57:00 【weixin_43224306】
- 基本介绍
适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示,主的目的是兼容性,让原本因接口不匹配不能一起工作的两个类可以协同工作。其别名为包装器(Wrapper)
适配器模式属于结构型模式
主要分为三类:类适配器模式、对象适配器模式、接口适配器模式
1. 现实生活中的适配器例子
泰国插座用的是两孔的(欧标),可以买个多功能转换插头 (适配器) ,这样就可以使用了。
2. 基本介绍
适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示,主的目的是兼容性,让原本因接口不匹配不能一起工作的两个类可以协同工作。其别名为包装器(Wrapper)
适配器模式属于结构型模式
主要分为三类:类适配器模式、对象适配器模式、接口适配器模式
3. 工作原理
适配器模式:将一个类的接口转换成另一种接口.让原本接口不兼容的类可以兼容
从用户的角度看不到被适配者,是解耦的
用户调用适配器转化出来的目标接口方法,适配器再调用被适配者的相关接口方法
用户收到反馈结果,感觉只是和目标接口交互,如图
边栏推荐
- STM32__ 06 - single channel ADC
- 18.(arcgis api for js篇)arcgis api for js点采集(SketchViewModel)
- 15 MySQL-存储过程与函数
- Make a short video clip number of we media film and television. Where can I download the material?
- [binary search tree] add, delete, modify and query function code implementation
- What are Yunna's fixed asset management systems?
- 【luogu CF487E】Tourists(圆方树)(树链剖分)(线段树)
- NSSA area where OSPF is configured for Huawei equipment
- 跟着CTF-wiki学pwn——ret2libc1
- How much do you know about the bank deposit business that software test engineers must know?
猜你喜欢

Mathematical model Lotka Volterra

Configuring OSPF load sharing for Huawei devices

Yunna | what are the main operating processes of the fixed assets management system

同事悄悄告诉我,飞书通知还能这样玩

How to get all the values stored in localstorage

零犀科技携手集智俱乐部:“因果派”论坛成功举办,“因果革命”带来下一代可信AI

Rsync remote synchronization

C# 反射与Type

21. PWM application programming

JVM details
随机推荐
同事悄悄告诉我,飞书通知还能这样玩
Russian Foreign Ministry: Japan and South Korea's participation in the NATO summit affects security and stability in Asia
总结了 800多个 Kubectl 别名,再也不怕记不住命令了!
FFmpeg学习——核心模块
Zero rhino technology joined hands with the intelligence Club: the "causal faction" forum was successfully held, and the "causal revolution" brought the next generation of trusted AI
PV static creation and dynamic creation
USB Interface USB protocol
[EF core] mapping relationship between EF core and C data type
上门预约服务类的App功能详解
What are the functions of Yunna fixed assets management system?
Redis高可用——主从复制、哨兵模式、集群
Spreadjs 15.1 CN and spreadjs 15.1 en
时区的区别及go语言的time库
Laser slam learning record
C file and folder operation
激光slam学习记录
Upgrade openssl-1.1.1p for openssl-1.0.2k
C# 反射与Type
如何获取localStorage中存储的所有值
rsync远程同步