I am working together with a senior C++ developer. In most of his code he includes debug sections. It looks like this:
void do_something() {
int var = 10
#ifndef NODEBUG
trace("Function Start %s", __FUNCTION__);
#endif
while (someCondition) {
var += 1
#ifndef NODEBUG
trace ("Var = %d \n", var)
#endif
}
... (Do some other stuff)
... (Do some more stuff)
#ifndef NODEBUG
trace("Function End %s", __FUNCTION__);
#endif
}
I am not as experienced as he is, but these code snippets are all over the code and this really clogs the readability and the understandability. In my oppinion the preprocessor conditions should AT LEAST be properly intended with the rest of the code.
Is this practise something that I should form a habit of? I am not sure if this a good way but in my opinion this immensely bloats the code and should be left out.