Does adding a variable assignment (for the purpose of enhancing the Debugging process) to the following type of method slow down execution by more than a second (1k ms) over ~1k calls?
Am I correct in my assumption that the variable will fall out of scope and be garbage collected when the method completes execution?
Refactoring this method:
public String concatenateOneOrTwo(String input, boolean one){
if(one){
return concatenate(input, "one");
}else{
return concatenate(input, "two");
}
}
To something like this:
public String concatenateOneOrTwo(String input, boolean one){
String returnValue = "";
if(one){
returnValue = concatenate(input, "one");
}else{
returnValue = concatenate(input, "two");
}
return returnValue;
}
This minor refactor could improve the debugging process; This would allow the developer to easily inspect the return value and enhance the maintainability of the code.
Additional Resources
public String concatenate(String one, String two){
return one + two;
}