Adapter

AKA: Wrapper

When an object or class has an API that cannot or should not be changed, but you need it to have some significant change to adapt to a different use case, then you need an Adapter. You might have two libraries that need access to the same instance but don’t share a common interface. It might be a legacy object which needs a new feature to support a change while keeping old code untouched.

There are two types of Adapter. The first is a class adapter; they wrap the class so you can create new objects pre-adapted. The new objects work as drop-in replacements for the old object type. The second type is an object adapter; it acts as an intermediary, holding the adaptee and forwarding calls through to it while reinterpreting the API where necessary.

“Let me translate for you.”