Adapter

Learn about a structural design pattern: the adapter pattern.

The adapter pattern is a structural pattern and probably one of the simplest design patterns there are, as well as being one of the most useful ones at the same time.

Press + to interact

Also known as a wrapper, this pattern solves the problem of adapting interfaces of two or more objects that are not compatible.

Usage of the adapter pattern

We typically encounter a situation where part of our code works with a model or set of classes that were polymorphic with respect to a method.

Working with an example

For example, if there are multiple objects for retrieving data with a fetch() method, then we want to maintain this interface so we ...