当前位置:网站首页>【DesignMode】适配器模式(adapter pattern)
【DesignMode】适配器模式(adapter pattern)
2022-07-05 23:57:00 【weixin_43224306】
- 基本介绍
适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示,主的目的是兼容性,让原本因接口不匹配不能一起工作的两个类可以协同工作。其别名为包装器(Wrapper)
适配器模式属于结构型模式
主要分为三类:类适配器模式、对象适配器模式、接口适配器模式
1. 现实生活中的适配器例子
泰国插座用的是两孔的(欧标),可以买个多功能转换插头 (适配器) ,这样就可以使用了。
2. 基本介绍
适配器模式(Adapter Pattern)将某个类的接口转换成客户端期望的另一个接口表示,主的目的是兼容性,让原本因接口不匹配不能一起工作的两个类可以协同工作。其别名为包装器(Wrapper)
适配器模式属于结构型模式
主要分为三类:类适配器模式、对象适配器模式、接口适配器模式
3. 工作原理
适配器模式:将一个类的接口转换成另一种接口.让原本接口不兼容的类可以兼容
从用户的角度看不到被适配者,是解耦的
用户调用适配器转化出来的目标接口方法,适配器再调用被适配者的相关接口方法
用户收到反馈结果,感觉只是和目标接口交互,如图
边栏推荐
猜你喜欢

【二叉搜索树】增删改查功能代码实现

18.(arcgis api for js篇)arcgis api for js点采集(SketchViewModel)

【在线聊天】原来微信小程序也能回复Facebook主页消息!

FFMPEG关键结构体——AVFrame

教你在HbuilderX上使用模拟器运行uni-app,良心教学!!!

Detailed explanation of APP functions of door-to-door appointment service

云呐|固定资产管理系统主要操作流程有哪些

Wechat applet -- wxml template syntax (with notes)

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?

亲测可用fiddler手机抓包配置代理后没有网络
随机推荐
China Jinmao online electronic signature, accelerating the digitization of real estate business
Initialiser votre vecteur & initialisateur avec une liste Introduction à la Liste
Research notes I software engineering and calculation volume II (Chapter 1-7)
Open source CRM customer relationship system management system source code, free sharing
总结了 800多个 Kubectl 别名,再也不怕记不住命令了!
Transport layer protocol ----- UDP protocol
Permission problem: source bash_ profile permission denied
选择致敬持续奋斗背后的精神——对话威尔价值观【第四期】
激光slam学习记录
亲测可用fiddler手机抓包配置代理后没有网络
GD32F4xx uIP协议栈移植记录
Learn PWN from CTF wiki - ret2libc1
21. PWM application programming
提升工作效率工具:SQL批量生成工具思想
Cloudcompare & PCL point cloud randomly adds noise
Bao Yan notebook IV software engineering and calculation volume II (Chapter 8-12)
云呐|固定资产管理系统功能包括哪些?
DEJA_ Vu3d - cesium feature set 055 - summary description of map service addresses of domestic and foreign manufacturers
上门预约服务类的App功能详解
15 MySQL-存储过程与函数