Weekly Dev Tips

Adapter Design Pattern

4 snips
Apr 15, 2020
Ask episode
AI Snips
Chapters
Transcript
Episode notes
INSIGHT

Adapters Decouple Clients From Providers

  • Adapters decouple clients from service providers by allowing incompatible combinations to work together.
  • They let both client and provider evolve independently while preserving interoperability.
ADVICE

Use Adapters To Avoid Widespread Changes

  • Introduce an adapter when a new service provider has an incompatible interface to avoid changing clients everywhere.
  • Let the adapter expose the old interface and translate calls to the new provider behind the scenes.
ANECDOTE

Logging Example Shows Adapter Use

  • Steve describes a logging example where an app uses one logging method everywhere and a new logger has a different signature.
  • He suggests wrapping the new logger with an adapter so existing calls keep working.
Get the Snipd Podcast app to discover more snips from this episode
Get the app