โ† CS Visual Lab ยท Design Patterns

๐Ÿ”Œ Adapter

๐Ÿ’ก The ideaWrap an existing class so its interface matches the one your code expects, without changing either side.
๐Ÿ  In real lifeA travel plug adapter: your Indian charger fits a UK socket without changing the charger or the wall.

๐ŸŽฌ Watch it work

Step 1 of 4
What your code expects

Your app pays through one interface.

interface PaymentGateway { pay(rupees: number): Promise<string> }

โœ… Check yourself (2 of 3 to pass)

1. Adapter is a โ€ฆ pattern.
2. Adapter is used when:
3. A real-life adapter is:
Next: Decorator โ†’Get a free certificate in Design Patterns