Design pattern:Adapter 设计模式:适配器

Categories: Java; Tagged with: ; @ July 19th, 2012 11:04

Adapter pattern(Wrapper pattern), is a design pattern that allows classes to work together, those classes can not work normally because they have incompatible interface.
For example, you travel from US to China, you need to use an adapter so that you charger can work, because they have different standard.

There are two types, one is Class level, and the other is Object(Instance) level.
Class Adapter pattern:

“The adapter is created by implementing or inheriting both the interface that is expected and the interface that is pre-existing. It is typical for the expected interface to be created as a pure interface class, especially in languages such as Java that do not support multiple inheritance

(http://en.wikipedia.org/wiki/Adapter_pattern)

Object Adapter pattern

Adapter contains an instance of the class it wraps, so that the adapter can delegate the request to warped instance.

 

<->



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.