Skip to content
Commitwise
Menu

Adapter

Also called: Wrapper

A wrapper that makes a class with a different interface usable through the interface your code expects.

Definition

An adapter implements your interface and translates every call to the wrapped class: names, parameters, units, formats, errors and callback styles. Placed at the edges of an app, adapters keep vendor SDKs and external APIs from leaking into the rest of the code, so replacing a vendor touches one class.

In practice

A PayFastAdapter implements PaymentGateway.charge(cents:) by converting cents to a decimal amount and calling the PayFast SDK.

Related terms

Esc

Type to search the whole site.