Extract class pull up method extract method

Problem: Duplicate code smell is found in two classes AddTransactionAction and AddNestedTransactionsAction, where the method validate() is present in both classes.

Step 1: Extracted a new class TransactionValidation and pulled-up the validate method to the new class. Made AddTransactionAction and AddNestedTransactionsAction to extend theTransactionValidation parent class. After this change the validate functions were tested and the validation of the amount and accounts are working properly.


Step 2: Removed the validate method from both the classes AddNestedTransactionsAction and AddTransactionAction to eliminate duplicate code. Then, create object for the new parent class  and the reference of it can be used to call the validate method wherever it is used. Here, the ValidateTxAction uses the validate method, so a reference of TransactionValidation class can be used to implement the alidate method. After this change the validate functions are tested and it is working properly.


Step 3: After extracting super class and pulling up the validate method,to make to mode readable and to avoid long, complicated code we implemented decompose conditional and extract method.A complex conditional statement is decomposed and checkLength is used instead of the complex conditional. Then, complex code under each if statement is extracted into separate methods like checkAccountDuplication(resp) using the extract method refractoring.