Adapter প্যাটার্ন অসামঞ্জস্যপূর্ণ ইন্টারফেসগুলিকে একসাথে কাজ করতে দেয় একটিকে অন্যটি প্রত্যাশা করে এমন ইন্টারফেসের সাথে মোড়িয়ে দিয়ে। এটি দুটি ইন্টারফেসের মধ্যে একটি অনুবাদক হিসাবে কাজ করে, বিদ্যমান কোড সংশোধন না করে ইন্টিগ্রেশন সক্ষম করে।
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.();
