Skip to content

Latest commit

 

History

History
36 lines (20 loc) · 843 Bytes

adapter-pattern.md

File metadata and controls

36 lines (20 loc) · 843 Bytes

Adapter Design Pattern

Adapter pattern allows incompatible classes to work together by converting the interface of one class into another expected by the clients.

Problem

Solution

Object Adapter

Object Adapter Structure

  • Client Contains business logic of the program.

  • Client Interface

Describes a protocol that other classes must follow to collaborate with the client code.

  • Adaptee (Service)

The useful 3rd-party/legacy class. Client code cannot use this directly because of incompatible interface.

  • Adapter
    • implements the client interface
    • wraps the service object

Class Adapter

Class Adapter Structure

  • Adapter

Inherits behaviors from both the client and the service.

Caveats