liveBook · Manning

Adapter

As explained in The Art of Code

A compatibility adapter is an intermediary component that translates between an older interface or data format and a newer one.

A compatibility adapter preserves an existing interface by translating between an older format and a newer one. Existing clients keep working while newer behavior is introduced alongside the old contract. section 9.4.2

Use an adapter when evolving an exposed system:

  • Place an intermediary layer between existing clients and the new format. section 9.4.2
  • Keep older methods available long enough for users to plan migration, even when they are deprecated. section 9.4.2
  • Weigh reduced client disruption against added maintenance overhead and the risk of hiding design debt. section 9.4.2

Preserving a changing endpoint

If an endpoint URL or response format changes, an adapter can translate requests or data so existing client applications continue using the older contract while the newer interface is adopted. section 9.4.2

@Deprecated(since = "2.1", forRemoval = true)
public void generateReport() { ... }

Deprecation markers make the migration boundary visible while the older entry point remains available. section 9.4.2

How The Art of Code covers it

How deep it goes
Defines the translation layer and weighs its maintenance cost, but stops short of implementation detail.
Examples
Uses changing endpoint URLs, old and new formats, deprecated methods, and versioned entry points as compatibility cases.
What it assumes
Assumes familiarity with exposed interfaces, client applications, and migration; defines the adapter’s compatibility role.
What you can do after
Evaluate when translation layers can reduce disruption and when their maintenance burden outweighs the benefit.
How it connects
Connects backward compatibility with interface evolution, deprecation, versioning, and maintenance overhead.

Also explained in

Compare how 9 books explain adapter →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Art of Code. The section links point to the parts of the book it draws on.