I was in a code review a couple of days ago and noticed one of my coworkers
never used for() loops. Instead, he would use while() loops such as the
i = 0;
while (i < n)
My initial reaction to seeing a while() loop is that the developer is doing
something *other* than one would have done with a for() loop. That is,
perhaps there is a special termination condition in the loop. Perhaps the
index is changed. But in this case the developer was doing absolutely
nothing different than the equivalent for() loop would have done. He had
just chosen to use a while() loop. As such, his implementation was
difficult for me to read.
So, I brought this up and the developer's position was that I was being
picky. He thought that hand-rolling his own for() loops was a reasonable
demonstration of an acceptable difference in style. Since the two of us
disagreed I thought I'd poll any readers on this group that felt like
Do you think that this type of structure is reasonable code? Or do you
think that the "common" implementation should be mandated? Am I being too
picky and should I just chill out?
Remove .nospam from my e-mail address to contact me.