Design Pattern Download: The Adapter Pattern

Example

When to use the Adapter?

  • When you want to utilize an existing class but have incompatible interfaces (i.e. EU vs US interface)

What is the Builder Pattern composed of?

  • The Target Service (this is the class we want to interact with, in our case this is the EUSocket)
  • The Existing Object (this is a class which we currently have but is incompatible with our Service, in our case this is the US plug)
  • The Adapter Class (this is a class which takes in a reference to our existing object and allows it to interact with our service, in this case it is our adapter)

Implementation

The Target Service

The Existing Object

The Adapter (and EU plug)

--

--

--

I am a software engineer working for Amazon living in SF/NYC.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AWS IoT without having to RTFM

Testing your Terraform code — Part 1

[ANN] MIR4 XDRACO, DSP, NFT item teaser site opens

How I “scaled” my SaaS database and broke my app.

What Is Sound?& Import Sound in Python.

Choosing the Right Hosting Service for Your Mobile App

The Art of Minimalism

Introducing Docker and Azure Functions

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Matthew MacFarquhar

Matthew MacFarquhar

I am a software engineer working for Amazon living in SF/NYC.

More from Medium

Java — Overview

A Glance on Conversion from Bytecode to Class Objects in JVM

Java Streams — A quick primer and application

How I stopped worrying and learned to love regular expressions