The program is working, no it's time to profile and optimize it or do some refactoring.
So, I just need to change logic1 to logic2 in some part of a program. I do so, and the program works differently. OK, let get previous version from git and compare code in some merging program. No ideas? OK, lets put more logging into both versions to see what is the difference. Mmm, still no ideas?
The solution is simple: add implementation of logic2 to the existing program and put bunch of assertions, that the results are equivalent to logic1. Like this:
foo(logic1_params, logic2_param){
// old code for logic1
logic1 res = ...
//new code for logic2
logic2_res = ...
assert(logic1_res == logic2_res);
return logic1_res;
}
If assertion fails, at least you know where he problem is.
After all assertion are fine, step by step replace return logic1_res; by return logic2_res;
and see what happens)
Important: I don't have unit tests (too expensive for research programs), but I have tests for the system and big modules to warn me if I screw up.
So, I just need to change logic1 to logic2 in some part of a program. I do so, and the program works differently. OK, let get previous version from git and compare code in some merging program. No ideas? OK, lets put more logging into both versions to see what is the difference. Mmm, still no ideas?
The solution is simple: add implementation of logic2 to the existing program and put bunch of assertions, that the results are equivalent to logic1. Like this:
foo(logic1_params, logic2_param){
// old code for logic1
logic1 res = ...
//new code for logic2
logic2_res = ...
assert(logic1_res == logic2_res);
return logic1_res;
}
If assertion fails, at least you know where he problem is.
After all assertion are fine, step by step replace return logic1_res; by return logic2_res;
and see what happens)
Important: I don't have unit tests (too expensive for research programs), but I have tests for the system and big modules to warn me if I screw up.