<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Adapter</title>
	<atom:link href="https://www.aitaocui.cn/tag/176650/feed" rel="self" type="application/rss+xml" />
	<link>https://www.aitaocui.cn</link>
	<description>翡翠玉石爱好者聚集地</description>
	<lastBuildDate>Wed, 23 Nov 2022 03:35:52 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1.1</generator>

<image>
	<url>https://www.aitaocui.cn/wp-content/uploads/2022/11/taocui.png</url>
	<title>Adapter</title>
	<link>https://www.aitaocui.cn</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Adapter(接口转换器)</title>
		<link>https://www.aitaocui.cn/article/280095.html</link>
					<comments>https://www.aitaocui.cn/article/280095.html#respond</comments>
		
		<dc:creator><![CDATA[取法乎上]]></dc:creator>
		<pubDate>Wed, 23 Nov 2022 03:35:52 +0000</pubDate>
				<category><![CDATA[百科]]></category>
		<category><![CDATA[Adapter]]></category>
		<guid isPermaLink="false">https://www.aitaocui.cn/?p=280095</guid>

					<description><![CDATA[适配器模式（Adapter）的定义如下：将一个类的接口转换成客户希望的另外一个接口，使得原本由于接口不兼容而不能一起工作的那些类能一起工作。适配器模式分为类结构型模式和对象结构型模...]]></description>
										<content:encoded><![CDATA[</p>
<article>
<p>适配器模式（Adapter）的定义如下：将一个类的接口转换成客户希望的另外一个接口，使得原本由于接口不兼容而不能一起工作的那些类能一起工作。适配器模式分为类结构型模式和对象结构型模式两种，前者类之间的耦合度比后者高，且要求程序员了解现有组件库中的相关组件的内部结构，所以应用相对较少些。</p>
</article>
<article>
<h1>基本内容</h1>
<p>电源适配器是小型便携式电子设备及电子电器的供电电源变换设备，一般由外壳、电源变压器和整流电路组成，按其输出类型可分为交流输出型和直流输出型；按连接方式可分为插墙式和桌面式。移动PC由于电池容量有限，电源适配器对其尤为重要。多数移动PC的电源适配器可以自动检测100～240V交流电(50/60Hz)。基本上所有的移动PC都把电源外置，用一条线和主机连接，这样可以缩小主机的体积和重量，只有极少数的机型把电源内置在主机内。现在NOKIA的手机配的存储卡中，适配器也是这样写的！</p>
<h1>数据配器</h1>
<p>用法：DataSet ds = new DataSet();SqlConnection conn = new SqlConnection(strconnection);//创建数据适配器对象SqlDataAdapter sda = new SqlDataAdapter(strSQL,s);//填充ds数据集，并创建新表sda.Fill(ds,tb）。</p>
<h1>设计模式之适配器模式（Java举例）</h1>
<h2 id="a-93415cfc">Adapter定义</h2>
<p>将一个类的接口变换成客户端所期待的一种接口，从而使原本因接口不匹配而无法在一起工作的两个类能够在一起工作。</p>
<h2 id="a-28bd6ab5">对象适配器</h2>
<p>继承自需要被适配的类，并且实现目标类的接口。</p>
<h2 id="a-6d5e5bc9">类适配器</h2>
<p>将需要被适配的类的对象作为自己私有属性，实现目标类的接口。</p>
<h2 id="a-8b250bd5">要点</h2>
<p>1.适配器模式主要应用于“希望复用一些现存的类，但是接口又与复用环境要求不一致的情况”，在遗留代码复用、类库迁移等方面非常有用。</p>
<p>2.适配器模式有对象适配器和类适配器两种形式的实现结构，但是类适配器采用“多继承”的实现方式，带来了不良的高耦合，所以一般不推荐使用。对象适配器采用“对象组合”的方式，更符合松耦合精神。</p>
<h2 id="a-f080b7f9">优点</h2>
<p>1.可以使两个没有关系的类在一起运行。</p>
<p>2.增加了类的透明性。</p>
<p>3.提高了类的复用。</p>
<p>4.灵活性好。</p>
<h2 id="a-1a2e8773">说明</h2>
<p>适配器模式是一个补偿模式，或者说是一个补救模式，通常来解决接口不相容的问题。一般来说最初设计的时候不会考虑这个模式，只是在有了新的业务需求时，这个是一个补救的模式。 </p>
</article>
<div class="mt-3 mb-3" style="max-width: 770px;height: auto;">
                                    </div>
<div class="mt-3 mb-3" style="max-width: 770px;height: auto;">
                                    </div>
<div class="mt-3 mb-3" style="max-width: 770px;height: auto;">
                                    </div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.aitaocui.cn/article/280095.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
