Bird
Raised Fist0

When a Proxy pattern is implemented to manage access to a heavy database connection, what is the primary role of the Proxy when a client requests data?

easy🧠 Technical Reasoning Q3 of Q15
OOP & Design Patterns - Adapter vs Facade vs Proxy - Structural Pattern Comparison
When a Proxy pattern is implemented to manage access to a heavy database connection, what is the primary role of the Proxy when a client requests data?
AIt controls access by creating the connection only when needed and may cache results.
BIt directly modifies the database schema to optimize queries.
CIt replaces the database with a simpler in-memory data store.
DIt exposes all database internals to the client for full control.
Step-by-Step Solution
Solution:
  1. Step 1: Understand Proxy's role

    The Proxy controls access to the real object, often delaying expensive operations.
  2. Step 2: Analyze the scenario

    For a heavy database connection, the Proxy creates the connection lazily and may cache data.
  3. Final Answer:

    It controls access by creating the connection only when needed and may cache results. -> Option A
  4. Quick Check:

    Proxy manages access and resource usage [OK]
Quick Trick: Proxy delays expensive operations until necessary [OK]
Common Mistakes:
MISTAKES
  • Thinking Proxy modifies the underlying resource
  • Assuming Proxy exposes internals directly
  • Confusing Proxy with Adapter or Facade
Trap Explanation:
PITFALL
  • Options suggesting Proxy modifies or exposes internals confuse Proxy with other patterns.
Interviewer Note:
CONTEXT
  • Tests understanding of Proxy's lazy initialization and access control.
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