Learn the vocabulary of wrapping an incompatible interface in a thin translation layer calling code can use directly.
0 / 5 completed
1 / 5
At standup, a dev mentions wrapping an existing class with an incompatible interface inside a thin translation layer, so that calling code can use it through the interface it actually expects. What is this design pattern called?
The adapter pattern is exactly this: the adapter pattern wraps an existing class with an incompatible interface inside a thin translation layer that implements the interface calling code actually expects, forwarding each call through to the wrapped class in a compatible way. A hash collision is an unrelated hash-table concept about two keys sharing a bucket. This wrap-and-translate approach is exactly why the adapter pattern lets an existing class be reused with new calling code without modifying that class's original interface.
2 / 5
During a design review, the team applies the adapter pattern to integrate a third-party library whose interface doesn't match the interface the rest of the codebase expects, specifically because wrapping it in a translation layer avoids modifying the third-party library's own source. Which capability does this provide?
The adapter pattern here provides Reuse of an incompatible interface without modifying its source, since a thin translation layer exposes the expected interface and forwards calls to the original class, leaving the third-party library's own code completely untouched. Modifying the third-party library's own source code directly to match the expected interface is often impossible or unwise, especially for a dependency maintained outside the team. This wrap-without-modifying-the-source behavior is exactly why the adapter pattern is favored for integrating third-party or legacy code with an incompatible interface.
3 / 5
In a code review, a dev notices a third-party library's incompatible interface is being reused by editing a locally maintained fork of that library's own source code to match the interface the rest of the codebase expects, instead of wrapping it in a thin translation layer. What does this represent?
This is a missed adapter-pattern opportunity, since wrapping the library in a thin translation layer would expose the expected interface without ever touching the library's own source, instead of maintaining an edited fork of it. A cache eviction policy is an unrelated concept about discarded cache entries. This edited-fork pattern is exactly the kind of maintenance burden a reviewer flags once a plain wrapper would achieve the same compatibility without forking anything.
4 / 5
An incident report shows upgrading a third-party library became painful because the team maintained an edited fork of its source to match the codebase's expected interface, and every upstream update had to be manually reapplied to that fork, instead of using a thin translation layer. What practice would prevent this?
Introducing the adapter pattern keeps the third-party library's own source untouched and upgradable directly from upstream, while a thin translation layer bridges the interface gap. Continuing to maintain an edited fork of the third-party library's source to match the expected interface regardless of how often the upstream library gets updated is exactly what caused the issue described in this incident. This adapter-based approach is the standard fix once upstream upgrades become painful due to a maintained fork.
5 / 5
During a PR review, a teammate asks why the team reaches for the adapter pattern instead of simply editing the third-party library's own source to match the interface the codebase expects. What is the reasoning?
The adapter pattern wraps the incompatible interface in a translation layer, leaving the third-party library's own source untouched and directly upgradable from upstream, while editing the library's source directly creates a maintained fork that must be manually kept in sync with every upstream update. This is exactly why the adapter pattern is favored for integrating third-party dependencies, while editing the source directly remains a maintenance liability.