Module 23 Β· Design Patterns (All 23 GoF) β Lesson 6 of 23 Β· ~6 min
Adapter
Adapter: make a foreign interface fit yours
Problem: a third-party object exposes the wrong method names, but you don't want that leaking through your whole codebase.
PawWalk scenario: a geocoder gem returns lat_lng, but your code everywhere calls .coordinates. Wrap the gem in an adapter that exposes coordinates and delegates.
The adapter owns the vocabulary translation so the rest of your app speaks only your interface.