A colleague once said that God is killing a kitten every time I write a for-loop.
When asked how to avoid for-loops, his answer was to use a functional language. However
Any construct in any language is there for a reason. It's a tool to be used to accomplish a task. Means to an end. In every case, there are manners in which to use it appropriately, that is, in a clear and concise way and within the spirit of the language AND manners to abuse it. This applies to the much-misaligned goto
statement as well as to your for
loop conundrum, as well as while
, do-while
, switch/case
, if-then-else
, etc. If the for
loop is the right tool for what you're doing, USE IT and your colleague will need to come to terms with your design decision.