SpinTheMic
Pro

Interview practice question

Growing if-else for payment methods

Backend Engineering · OOP and Design Patterns · Beginner

Your checkout code has a growing if-else chain for card, PayPal, Apple Pay and bank transfer, and each new method means editing it. How do you improve it?

What a strong answer covers

Your AI report card counts how many of these ideas you cover.

  • Strategy pattern.
  • PaymentMethod interface with process().
  • One class per method.
  • Registry/factory selects by type.
  • New method = new class.
Practise this topic

Start without signing up. Sign in free to get an AI report card on your answer.

See all topics