Bird
Raised Fist0

You need to integrate a third-party library with an interface incompatible with your existing system. Which structural pattern best fits this scenario?

easy🔍 Pattern Recognition Q1 of Q15
OOP & Design Patterns - Adapter vs Facade vs Proxy - Structural Pattern Comparison
You need to integrate a third-party library with an interface incompatible with your existing system. Which structural pattern best fits this scenario?
AFacade, to provide a simplified interface to the complex third-party library
BAdapter, to convert the third-party interface into one compatible with your system
CProxy, to control access to the third-party library and add caching
DDecorator, to add responsibilities dynamically to the third-party library
Step-by-Step Solution
Solution:
  1. Step 1: Identify the problem of interface incompatibility

    The third-party library interface is incompatible with the existing system, so we need to convert it.
  2. Step 2: Match pattern intent to interface conversion

    Adapter pattern is specifically designed to convert one interface to another compatible interface.
  3. Step 3: Why other options are incorrect

    Facade simplifies a complex subsystem but does not convert interfaces; Proxy controls access but does not adapt interfaces; Decorator adds responsibilities dynamically but does not change interfaces.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    Adapter converts interfaces; Facade simplifies them [OK]
Quick Trick: Adapter converts interfaces; Facade simplifies them [OK]
Common Mistakes:
MISTAKES
  • Confusing Facade with Adapter
  • Thinking Proxy adapts interfaces
  • Assuming Decorator changes interfaces
Trap Explanation:
PITFALL
  • Candidates often confuse Facade's simplification role with Adapter's interface conversion role.
Interviewer Note:
CONTEXT
  • Tests candidate's ability to distinguish Adapter from Facade and Proxy patterns.
Master "Adapter vs Facade vs Proxy - Structural Pattern Comparison" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes