I need to add a new payment type to an existing code base. That means that I'm going to have a few methods looking like this:
if (old payment type)
process old type of payment
else
process new type of payment
Now, if this could have been determined beforehand, I would have this method point to an interface implementing a common Pay method and then that interface would be implemented by one of two classes. Unfortunately, I only know which method the customer chooses at runtime, which means I need a way to determine which branch to use. Is there another way except for just having if
s spread through the code?