The Adapter Pattern
Learn how to use the Adapter pattern to build an fs-like interface that writes to LevelDB instead.
We'll cover the following
The Adapter pattern allows us to access the functionality of an object using a different interface.
A real-life example of an adapter would be a device that allows us to plug a USB Type-A cable into a USB Type-C port. In a generic sense, an adapter converts an object with a given interface so that it can be used in a context where a different interface is expected.
In software, the Adapter pattern is used to take the interface of an object (the adaptee) and make it compatible with another interface that’s expected by a given client. Let’s take a look at the illustration below to clarify this idea.
Get hands-on with 1400+ tech skills courses.