Recall & Review
beginner
What is the Payment Strategy Pattern?
It is a design pattern that lets you choose different payment methods at runtime without changing the code that uses them. It helps keep payment logic separate and flexible.
Click to reveal answer
beginner
Why use the Payment Strategy Pattern in system design?
It allows adding new payment methods easily, supports multiple payment options, and keeps the code clean by separating payment logic from business logic.
Click to reveal answer
intermediate
Name the main components of the Payment Strategy Pattern.
1. Strategy Interface: defines payment method behavior.<br>2. Concrete Strategies: implement specific payment methods (e.g., credit card, PayPal).<br>3. Context: uses a strategy to perform payment.
Click to reveal answer
intermediate
How does the Context class interact with payment strategies?The Context holds a reference to a payment strategy and calls its payment method. It can switch strategies at runtime to support different payment options.
Click to reveal answer
beginner
Give a real-life example of the Payment Strategy Pattern.
An online store lets customers pay by credit card, PayPal, or gift card. Each payment method is a strategy. The store’s checkout system (context) uses the chosen strategy to process payment.
Click to reveal answer
What does the Payment Strategy Pattern help you do?
✗ Incorrect
The pattern allows switching payment methods easily without modifying the client code.
Which component defines the payment method interface in the Payment Strategy Pattern?
✗ Incorrect
The Strategy Interface defines the methods that all payment strategies must implement.
In the Payment Strategy Pattern, where is the payment method chosen?
✗ Incorrect
The Context class holds and uses the chosen payment strategy at runtime.
Which of these is NOT a benefit of using the Payment Strategy Pattern?
✗ Incorrect
Fraud detection is not handled by the Payment Strategy Pattern.
What role does the Concrete Strategy play?
✗ Incorrect
Concrete Strategies implement specific payment methods like credit card or PayPal.
Explain how the Payment Strategy Pattern improves flexibility in a payment system.
Think about how changing payment methods affects code.
You got /4 concepts.
Describe the roles of Context, Strategy Interface, and Concrete Strategies in the Payment Strategy Pattern.
Focus on how these parts work together.
You got /3 concepts.