Search⌘ K
AI Features

Dealing with Incompatible Code Structures

Understand how to apply the Adapter pattern to integrate incompatible code structures such as third-party libraries or legacy systems without modifying existing code. This lesson helps you learn to isolate interface conversions while adhering to design principles for scalable software.

Problem statement

Let’s imagine that we’re working with a third-party library that returns data in a specific format. The problem is, however, that this isn’t the data format that the rest of our application works with.

For example, our code might only be working with JSON, while the third-party library only delivers data as XML. In this situation, the last thing that we’d want to do is rewrite the rest of our code to make it compatible with XML, especially if we don’t expect anything other than this library to use XML.

There’s also another variety of this problem that we might encounter. Once again, ...