As usual, I have some code chain starting at the main method. Is there any elegant coding pattern, with which I could easily dump the outputs of all methods ever being called at runtime? I have one idea:
a) Copy the source code into an auxiliary aux:: namespace. For each method in aux:: run its copy of the code from the original:: namespace and after that dump its expected output).
Example pseudo-code:
// Source code at some repository
namespace original {
int B(int input){
output = input + 5;
return output;
}
int A(int input){
int output = methodB(input);
output--;
return output;
}
}
// Create auxiliary repo
namespace aux{
int B(int input){
output = input + 5;
// No other dependencies so only dump B output here
dump(output);
return output;
}
int A(int input){
int output = methodB(input); // would call aux::methodB
output--;
// Dump output of A
dump(output);
return output;
}
}
int main() {
// Normally I would run original::A() but now I am dumping
aux:A();
return 0;
}
This would work, but I would need to replace source content everytime the code in original:: changes. I'd like to device something nicer like reusing the definitions in original:: without copying into aux:: but I am kind of stuck there.
Any help would be much appreciated!