当前位置:网站首页>Over adapter mode
Over adapter mode
2022-07-25 06:28:00 【Little wolf】
Problem scenario :1、 I bought the Japanese version iPhone Telecom cards cannot be used in China , There was no signal , At this time, I need a card sticker , Card stickers are similar adapters that we are going to talk about today 2、 On the client side , A certain interface is displayed in red , And red is a binary value returned by the server , One day the server developer changed , He changed the binary value into 255 Bit rgb The number , Or some day it is changed into other forms , At this time, the idea of using adapter mode can better solve the problem .
The adapter pattern is generally divided into three roles : Adapter Adaptee agreement
Adapter : An object of active adaptation
Adaptee : An adapted object
agreement : To implement a set of behavioral agreements (iOS It usually appears in the form of agency agreement )
Process definition : The adapter executes a set of behavioral protocols , To solve the problems caused by compatibility
There are two adapter modes : Class adapter and object adapter (iOS Medium class adapters are used more )
The class adapter : The adapter inherits the Adaptee , The adapter executes a set of behavioral protocols , Adapters and adaptees The mate belongs to the inheritance relationship
Object adapter : The adapter applies the Adaptee through Association , The adapter executes a set of behavioral protocols , Adapters and adaptees The partner belongs to the relationship
Use different scenarios : When the Adaptee is many subclasses of a class , Using object adapters is more appropriate .
Be careful : Any design pattern adds files to the added code , In the process of actual use, it must be used according to the specific situation , Blindly pursuing design patterns is just asking for trouble , such as : If you have a project , It is only the modification of a field returned by the server , You can make judgments in the method of obtaining this field. Generally speaking , Large enough projects should focus on the convenience brought by design patterns , Easy : maintain , test , modify .
边栏推荐
- Design of automatic machine dot drawing script based on C language
- [Luogu p6629] string (runs) (tree array)
- Evolution of coupon architecture under C2B mode
- mysql 查询当前数据库下的表名
- MySQL中建表时 pk、nn、qu、b、un、zf、ai、g代表的意思
- 函数模板学习记录
- Ceres solver version 1.14 and eigen3.2.9
- Cout format output common functions and flags summary
- Common API of window
- Netease game Flink SQL platform practice
猜你喜欢

Dry goods | training AI model can't find data? Collect 20 selected open source communities!

Netease game Flink SQL platform practice
![[jailhouse article] base architectures for virtual physical computing (2018)](/img/ea/480d3e0743639d2f2e0d447b3ca050.png)
[jailhouse article] base architectures for virtual physical computing (2018)

Quick sort code implementation

SAP FICO section III BDC and ltmc import S4 financial account

It is said that screentogif is a GIF recording artifact, but I don't know that its strength is far from here

【Node】服务端口被占用Error: listen EADDRINUSE: address already in use :::9000-如何关闭node启动的端口

【transformer】DeiT

【C】程序环境和预处理

【transformer】DeiT
随机推荐
Evolution of coupon architecture under C2B mode
Typedef usage and template
51 timer initial value calculation
Binary search tree (day 75)
[sword finger offer] analog implementation ATOI
Installation and configuration of automatic operation and maintenance management workers ansible
4、 MFC toolbar, runtime class information mechanism, runtime creation mechanism
Brief tutorial of vbs script syntax (1)
"Everyday Mathematics" serial 61: March 1
C#控件开源库:MetroFramework的下载
[jailhouse article] base architectures for virtual physical computing (2018)
C control open source library: download of metroframework
C#开源控件MetroFramework Demo项目下载和运行
在C# WinForms应用程序中安装,配置和使用MetroFramework
"Wei Lai Cup" 2022 Niuke summer multi school training camp 2 link with game glitch (SPFA finds positive and negative links)
都说ScreenToGif是GIF录制神器,却不知其强大之处远不在此
“蔚来杯“2022牛客暑期多校训练营2 Link with Game Glitch (spfa找正负环)
target_ compile_ features specified unknown feature “cxx_std_14“ for target
[C language] document processing and operation
Do you know the same period last year in powerbi