0
0
LLDsystem_design~12 mins

Adapter pattern in LLD - Architecture Diagram

Choose your learning style9 modes available
System Overview - Adapter pattern

The Adapter pattern helps two incompatible interfaces work together. It acts like a translator between a client and a service that have different interfaces. This pattern is useful when you want to reuse existing code but the interfaces don’t match.

Architecture Diagram
User
  |
  v
Client Interface
  |
  v
Adapter
  |
  v
Adaptee (Existing Service)
Components
User
actor
Initiates requests using the client interface
Client Interface
interface
Defines the expected methods the user calls
Adapter
adapter
Converts client interface calls to adaptee interface calls
Adaptee (Existing Service)
service
Provides existing functionality with an incompatible interface
Request Flow - 6 Hops
UserClient Interface
Client InterfaceAdapter
AdapterAdaptee (Existing Service)
Adaptee (Existing Service)Adapter
AdapterClient Interface
Client InterfaceUser
Failure Scenario
Component Fails:Adapter
Impact:User requests cannot be translated to the adaptee interface, causing failures or errors in service calls.
Mitigation:Implement error handling in the adapter to catch translation errors and fallback to default behavior or notify the user gracefully.
Architecture Quiz - 3 Questions
Test your understanding
What is the main role of the Adapter in this pattern?
ATo replace the existing service
BTo translate calls between incompatible interfaces
CTo store data for the client
DTo act as the user interface
Design Principle
The Adapter pattern allows reuse of existing services with incompatible interfaces by introducing a translator component. This keeps client code unchanged and promotes flexibility.