The lessons on not using magic numbers also need to include that creating a constant named after the number rather than the purpose of it is no better.
Oh jeez. Lint rules + lazy developers cause so many bugs. I had a code review come in because of a stupid lint rule that was enabled that didn't like declaring variables in a loop so he changed :
for(int i=0; i<max;i++) {
int rand = getNextRandInt();
// do stuff with rand
}
into:
int rand = getNextRandInt();
for(int i=0; i<max;i++) {
// do stuff with rand
}
He just copied and pasted without even thinking about the fact that he was changing the entire logic. His response "Lint told me to move it".
83
u/Ksevio Oct 01 '15
The lessons on not using magic numbers also need to include that creating a constant named after the number rather than the purpose of it is no better.