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

Huawei equipment configuration ospf-bgp linkage
![[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!
![[noi simulation] Anaid's tree (Mobius inversion, exponential generating function, Ehrlich sieve, virtual tree)](/img/d6/c3128e26d7e629b7f128c551cd03a7.png)
[noi simulation] Anaid's tree (Mobius inversion, exponential generating function, Ehrlich sieve, virtual tree)

JVM details

18. (ArcGIS API for JS) ArcGIS API for JS point collection (sketchviewmodel)

【LeetCode】5. Valid palindrome

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?

Spreadjs 15.1 CN and spreadjs 15.1 en

总结了 800多个 Kubectl 别名,再也不怕记不住命令了!

认识提取与显示梅尔谱图的小实验(观察不同y_axis和x_axis的区别)
随机推荐
Wechat applet -- wxml template syntax (with notes)
15 MySQL stored procedures and functions
云呐|固定资产管理系统主要操作流程有哪些
哪些偏门项目可以做到?自媒体做到月赚一万以上很难吗?
Qt 一个简单的word文档编辑器
The use of El cascader and the solution of error reporting
C file and folder operation
如何让同步/刷新的图标(el-icon-refresh)旋转起来
Single merchant v4.4 has the same original intention and strength!
Miaochai Weekly - 8
Configuring OSPF load sharing for Huawei devices
关于结构体所占内存大小知识
【luogu CF487E】Tourists(圆方树)(树链剖分)(线段树)
5. Logistic regression
7.5 装饰器
Laser slam learning record
20220703 week race: number of people who know the secret - dynamic rules (problem solution)
QT a simple word document editor
Teach you to run uni app with simulator on hbuilderx, conscience teaching!!!
rsync远程同步