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*
-
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.user124– user1242021-03-21 13:45:41 +00:00Commented 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)Christophe– Christophe2021-03-21 13:56:57 +00:00Commented 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?user124– user1242021-03-21 14:05:46 +00:00Commented Mar 21, 2021 at 14:05
Add a comment
|
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
-
create code fences with backticks ` or tildes ~
```
like so
``` -
add language identifier to highlight code
```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible)
<https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-java