Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • But IPaymentDetail cannot be implemented by CreditCard,DebitCard etc. because these contains entirely different data.At high level these may be payment methods, but internally these are different things all together.Also even if somehow I manage to do this. Then at processPaymentDetail,I have to use if -else to see what is the type of the IPaymentDetail as If it is creditCard then call creditCard external Service and so on. Commented Mar 21, 2021 at 13:45
  • @user124 I just started the idea on how to bring true polymorphism into that. But you’re right: it will not be sufficient since payment processing shall be done by the payment processor and not by the credit card. There are chances that more objects will have to be involved to properly separate concerns and still allow for polymorphism (at least an IPaymentService) Commented Mar 21, 2021 at 13:56
  • I definitely need to have the api in paymentProcessor class for each type of payment. Whether they can be of same name or different , i think it does not matter,as at the client side, it should have similar 4-5 api where each api will receive its own input and then pass to payment processor.and the client cannot escape this logic, because if 4 clients use this,all of them have to use that 4-5 if -else, because these are different functionality they are trying to achieve and each functionality is a behaviour and hence an different api.What do you think? Commented Mar 21, 2021 at 14:05