I have a class contains 10 methods which are doing almost the same things apart from one key event. Two examples are given below:
Public String ATypeOperation(String pin, String amount){ doSomething(); doMoreStuff(); requestBuilder.buildATypeRequest(pin, amount); doAfterStuff(); }
Public String BTypeOperation(String name, String sex, String age){ doSomething(); doMoreStuff(); requestBuilder.buildBTypeRequest(name, sex, age); doAfterStuff(); }
As you can see from the above methods, they are similar apart from calling different methods provided by requestBuilder. The rest 8 are similar too. There is a lot duplicated code here. I feel there is a better way to implement this, but don’t know how. Any ideas and suggestions are appreciated.
Thanks, Sarah