Adapter 模式允许具有不兼容接口的对象通过用一个对象期望的接口包装另一个对象来协同工作。它充当两个接口之间的翻译器,无需修改现有代码就能实现集成。
适配器模式的作用
ADAPTER → convert one interface into another that a client expects (a "translator"):
→ wrap an object whose interface is INCOMPATIBLE, exposing the interface the client needs
→ the adapter translates calls/data between the two interfaces
→ makes incompatible things work together WITHOUT changing either's code
示例
{ () { } }
{
() { . = thirdParty; }
() { ..(msg); }
}
logger = ( ());
logger.();
