Medium Software Engineering Design Patterns
Explain the Adapter pattern with examples.
Answer
Adapter pattern allows incompatible interfaces to work together by wrapping one interface to match another. Like power plug adapters. Examples: wrapping legacy API to match new interface, adapting third-party libraries, database driver adapters (JDBC). Class adapter uses inheritance; object adapter uses composition (preferred). Benefits: reuse existing code, integrate incompatible systems, follows Single Responsibility. Different from Facade (simplifies) and Decorator (adds behavior). Common in integrations and migrations.
IIT Certified
Master These Concepts with IIT Certification
175+ hours of industry projects. Get placed at Bosch, Tata Motors, L&T and 500+ companies.
Relevant for Roles
Software Engineer Senior Developer Software Architect