Pattern · Core

Adapter

Convert the interface a class HAS into the interface a client EXPECTS — a wrapper that translates calls so incompatible code can work together.

Asked atAmazonMicrosoftStripe
step 1 / 9
1/2Interfaces don't match
App
+ play(media)
LegacyAudio
+ startAudio(f)
Interfaces don't match
1interface MediaPlayer { void play(String f); }
2class LegacyAudio { void startAudio(String f){ ... } }
3// app.play(...) ✗ — LegacyAudio has no play()

Your App is written to call play(media) on a MediaPlayer. That's the interface the rest of your code speaks.