Monday, 28 April 2014

Reducing the Number of File change and Recursion Testing



Scenario:

 Consider a scenario where two different services need to be provided based on different time line. The existing service has been referred in many places. The new service needs to be implemented with minimum number of file changes and less amount of testing time.



For example based on the Salary limit, year of experience the interest rate for the personal loan will be differed.  Consider the RBI has revised the Interest Rate. Now the older system should behave differently based on the timeline.

Older Implementation:


  

InterestCalculationService obj = new InterestCalculationService();

Service 1 Class
double interestRate = obj.getInterestCalculationService();
..
Service N Class
double interestRate = obj.getInterestCalculationService();

Before 2013 – The older interest calculation should be processed.
After 2013 - The new interest calculation should be processed.

InterestCalculationService obj = new InterestCalculationService();

Doing switch in each service methods and UI 

Service 1
 
if(Year after 2013){
obj . getInterestCalculationService1();
}
Else if(Year before 2013){
obj 1. getInterestCalculationService2();
}
  ... Service N


Here instead of changing the service call in every single UI interaction and service call. We can make the older service as kind of switching service which will redirect to two different services.




Keep the UI, Service calls as it is, don't change the older service name and class. Modify the existing service kind of switching service based on the timeline given.

Switching service (Older service or method)

if(Year after 2013){
obj. getInterestCalculationService1();
}
Else if(Year before 2013){
obj . getInterestCalculationService2();
}


Benefits

  • You will end up in touching very minimum number of files
  • You don’t want to do recursion on each and every service call. Just ensure the switching execution executes as expected.
  • Reduce the development, testing time. 


No comments:

Post a Comment