The Adapter pattern, also known as Wrapper, is a structural GoF design pattern by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides that converts the interface of a class into another interface clients expect. The adapter sits between client and existing class and translates calls, so a class whose interface does not match can be reused, for example to map a legacy API onto a new interface without changing existing code.

GoF-Adapter Pattern

Details
Full Name

GoF Adapter Pattern (Structural)

Also known as

Wrapper

Intent:

Convert the interface of a class into another interface clients expect.

When to Use:

  • When you want to use an existing class whose interface doesn’t match what you need

  • When you want to create a reusable class that cooperates with unrelated classes

Prompt Example:

"Erstelle einen Adapter nach GoF, der die Legacy-API auf unser neues Interface mappt, ohne den bestehenden Code zu ändern."