CHAPTER 8

image

Adapter Patterns

GoF Definition: Convert the interface of a class into another interface that clients expect. The adapter pattern lets classes work together that couldn’t otherwise because of incompatible interfaces.

Concept

The core concept is best described by the examples given below.

Real–Life Example

The most common example of this type can be found with mobile charging devices. If our charger is not supported by a particular kind of switchboard, we need to use an adapter. Even the translator who is translating language for one person is following this pattern in real life.

Computer World Example

In real-life development, in many ...

Get Java Design Patterns now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.