Adapter pattern
easy 50 minThe 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
| Choice | Reason | Cost | I would change it when |
|---|---|---|---|
| Object adapter | Loose, testable | One object more | I must override an inner step |
| One adapter per library | One reason to change | More small classes | The differences are one-liners, then functions |
| Own error types | Callers react, not parse | A mapping to maintain | Never at a border |
| Map from key to adapter | The client stays closed | Wiring in one place | Plug-ins arrive, then a registry |
| Own types as results | No leaks | Copying fields | Huge data, then a read-only view |
| Retry outside | Once for all vendors | One more wrapper | A vendor demands its own rhythm |