Bird
0
0

What is the primary purpose of the Payment Strategy Pattern in software design?

easy📝 Conceptual Q1 of 15
LLD - Design — Online Shopping Cart
What is the primary purpose of the Payment Strategy Pattern in software design?
ATo store payment details securely in a database
BTo allow multiple payment methods to be interchangeable without changing client code
CTo encrypt payment transactions end-to-end
DTo generate invoices automatically after payment
Step-by-Step Solution
Solution:
  1. Step 1: Understand the role of strategy pattern

    The strategy pattern allows selecting an algorithm's behavior at runtime without changing the client code.
  2. Step 2: Apply this to payment methods

    Payment strategy pattern lets different payment methods be used interchangeably by the client without modifying its code.
  3. Final Answer:

    To allow multiple payment methods to be interchangeable without changing client code -> Option B
  4. Quick Check:

    Payment Strategy Pattern purpose = Interchangeable payment methods [OK]
Quick Trick: Strategy pattern enables flexible payment method swapping [OK]
Common Mistakes:
  • Confusing strategy pattern with security features
  • Thinking it handles data storage
  • Assuming it automates invoicing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes