AlgoViz

Adapter pattern

easy 50 min

The Adapter pattern makes an existing class fit the interface that its client expects, without changing either of them.

Watch lesson4:39

Explain your choices

Answer first. Then compare your reasoning.

15 questions 0 got it 0 to review15 not marked

Defend

Choice, reason, cost, trigger

ChoiceReasonCostI would change it when
Object adapterLoose, testableOne object moreI must override an inner step
One adapter per libraryOne reason to changeMore small classesThe differences are one-liners, then functions
Own error typesCallers react, not parseA mapping to maintainNever at a border
Map from key to adapterThe client stays closedWiring in one placePlug-ins arrive, then a registry
Own types as resultsNo leaksCopying fieldsHuge data, then a read-only view
Retry outsideOnce for all vendorsOne more wrapperA vendor demands its own rhythm