Design Patterns II - Adapter

本文介绍了软件设计中的一种结构型模式——适配器模式。详细解释了适配器模式的作用:通过转换类的接口,使其符合客户端期望的形式,从而让原本因接口不兼容而无法协同工作的类能够一起工作。此外,还提供了适配器模式的统一建模语言(UML)表示,并列举了一些参考资源。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*

Author: Jiangong SUN

*/


There are 4 categories of design patterns called Gang of Four(GoF):

- Creational patterns

- Structural patterns

- Behavior patterns

- Concurrency patterns


Adapter pattern is a structural pattern.

Adapter pattern definition: Convert the interface of a class into another interface clients expect. An adapter lets classes work together that could not otherwise because of incompatible interfaces. The enterprise integration pattern equivalent is the translator.


UML:



For example, there are 2 targets that 2 different clients expects.








reference:

http://www.codeproject.com/Articles/342082/Understanding-and-Implementing-the-Adapter-Pattern

http://en.wikipedia.org/wiki/Design_pattern_%28computer_science%29#Classification_and_list

http://www.dofactory.com/Patterns/PatternAdapter.aspx

http://stackoverflow.com/questions/1673841/examples-of-gof-design-patterns

http://msdn.microsoft.com/en-us/library/orm-9780596527730-01-04.aspx

http://stackoverflow.com/questions/1299167/understanding-adapter-pattern

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值