I am writing a payment Processor class, then will take different payment objects in input and talks to external services to process payment.My class is designed using polymorphism as follow:
public class PaymentProcessor
{
DebitCardTransactionDetails processPayment(DebitCard);
CreditCardTransactionDetails processPayment(CreditCard)
NetBankingTransactionDetails processPayment(NetBanking)
...........................
...................
}
I am using same name,so that client dont have to worry about selecting the method based on paymentType using if-else,If I keep all api name different, then the client has to do if-else and select api to call.Here Client can call processPayment()
api and get the work done.Any downsides for this?I cannot think though.