# The Difference Between An Adapter And A Wrapper

DevFeed: [The Difference Between An Adapter And A Wrapper](<https://devfeed.tech/articles/the-difference-between-an-adapter-and-a-wrapper-22308.md>)

Original publisher: [Read original article](<https://www.thecodedself.com/The-Difference-Between-an-Adapter-and-a-Wrapper/>)

Author: Keegan Rush

Published: 2017-01-30T00:00:00Z

Content type: tutorial

Language: en

Sources: [The Coded Self](<https://devfeed.tech/sources/the-coded-self.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [Programming](<https://devfeed.tech/topics/programming.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [adapter-pattern](<https://devfeed.tech/tags/adapter-pattern.md>), [bridge](<https://devfeed.tech/tags/bridge.md>), [compatibility](<https://devfeed.tech/tags/compatibility.md>), [interface](<https://devfeed.tech/tags/interface.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [library](<https://devfeed.tech/tags/library.md>), [object](<https://devfeed.tech/tags/object.md>), [programming](<https://devfeed.tech/tags/programming.md>), [third-party](<https://devfeed.tech/tags/third-party.md>), [toolbox](<https://devfeed.tech/tags/toolbox.md>)

## AI overview

This article explains the difference between the adapter pattern and wrappers. Adapters bridge incompatible interfaces by transforming input, while wrappers encapsulate code to simplify and constrain its interface, often around external libraries.

## Source excerpt

The adapter pattern and wrappers each solve common but distinct problems. Their common usage and similarities in implementation, however, can lead to confusion. Both terms seem to be used interchangeably when in fact there are a few key differences. The adapter pattern and wrappers are two very useful tools and you can benefit from having them properly labeled in your toolbox. Definition Adapter: An adapter allows code that has been designed for compatibility with one interface to be compatible with another. An adapter accomplishes this by transforming the input meant for Interface A into compatible input for Interface B. It is a bridge between two existing interfaces. Wrapper: A wrapper encapsulates and hides the complexity of other code. The most common use of a wrapper is in the Facade pattern. Third-party code can be hard to use due to the fact that the exposed interface is made to accommodate many use cases. When you are only concerned about a subset of the features or the exposed interface, or you find that using the library is hard or tedious, then what you need is to wrap it in a simpler, more constrained interface. Differences Intention: The end product may look similar but the intention is different. A wrapper as used in the Facade pattern is intended to simplify an interface to an external library. An adapter is intended to bridge the disconnect between one interface and another. You may look at a new library that you wish to use and write a wrapper to simplify and streamline its use. You may look at an interface, internal or external, that your existing code needs to conform to, and write an adapter to do that. Composition: A wrapper contains another object and wraps around it. It has the the sole responsibility of moving data to and from the wrapped object. An adapter doesn't necessarily contain or simplify an object, although this can be a secondary benefit of using adapters. An adapter transforms input to make it match the input required by another in