Chapter    12

The Adapter Pattern

In this chapter, I describe the first of the structural patterns: the adapter pattern. This pattern allows two objects that provide related functionality to work together even when they have incompatible APIs. Table 12-1 puts the adapter pattern in context.

Table 12-1. Putting the Adapter Pattern into Context

Question

Answer

What is it?

The adapter pattern allows two components with incompatible APIs to work together by introducing an adapter that maps from one component to the other.

What are the benefits?

This pattern allows you to integrate components for which you cannot modify the source code into your application. This is a common problem when you use a third-party framework or when you are consuming the output ...

Get Pro Design Patterns in Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.