Here are some gems I have found looking through code. I am used to find a few strange things, however finding so many in one day was unexpected.
Copied & pasted into 2 separate places (seems good code after all :-):
...
sprintf(tmp, "%s ", "and");
...
Based on another function which had 2 case statements. I guess the key is future extensibility:
...
BOOL IsOfTypeXYZ(long nType)
{
switch (nType) {
case TYPE_XYZ:
return TRUE;
default:
break;
}
return FALSE;
}
.....
I confronted the developer about this one. The answer was indeed "future extensibility". I am showing the short instance (which is the worst). There also was an instance with more switch cases, and the stated reason for using the loop was "have to make sure the functions are called in a correct order and some parts of it have to be excluded with #ifndef's".
....
#define VAR_TYPE_1 0
....
for (int i = 0; i <= VAR_TYPE_1; i++) {
swtich(i){
case VAR_TYPE_1:
f1();
}
}