R
Richard
Ben Bacarisse said:<big snip>
I don't think there are any substantive issues there than this:
Why are you bringing up "easier to understand" -- I agreed about that
several messages ago?
The only issue I raised was maintainability. Now, I have admitted
that I don't really know what people mean here, but you brought it up
so it must mean something to you. I asked for an example of something
that, in your view impairs maintainability, but you did not offer one.
I thought it was obvious from the context. The less code needed to
understand a certain branch the better. That is one aspect of it.
Without that I will be at a disadvantage, because I don't know what I
mean by it and you haven't said what you mean by it!
Other people seem to hold that code is more maintainable if it can be
modified by making "local changes". I posited a change: add something
that has to be done every time after the loop's (current) body. To do
sure. In that case dont use continue : change it to an empty block
followed by an else. Easy enough
while(n--){
if(!cond(n)){
/*do nothing*/
}else{
/*do something*/
}
something to do all the time:
}
Not exactly rocket science.
that, if a loop has a continue, the maintenance programmer has to
check for that and either replace the continue with a goto or re-write
using an if that encloses the (current) body. Neither is what I
understand by a "local change".
This may not be what you mean by maintainability, in which case you
use is (by your criteria) unimpeachable, but it seems to match what I
think other people call maintainability.
Your example is fair and one aspect of it. It means many things to many
people.
But one of the most important is the ability to see what peoples code is
doing at a glance and assuming this code is working as desired I can
only consider that a total nOOb or fool would NOT understand what the
following code does for elements which do not match the criteria for
further processing:
Please don't repeat that your code if for cases where this change is
never warranted. If you can code for all future changes you should
write a book to tell the rest of how to do this. If, on the other
Where did I say that? I am merely saying (and as usual in c.l.c it gets
dragged through the bushes backwards) that "continue" is not an
indicator that code is poorly designed in any shape or form.
hand, you claim that this change is never need in loops that have this
specific pattern, then I'll shut up and just accept you have a much
deeper knowledge of code patterns than I have ever managed to attain
(but you should have brought up the fact that you know this never
happens when you offered the code pattern).
I offered the "pattern" for the reasons stated above. I'm sure you dont
mean to sound like you are posturing with your qualifications with that
last statement, but I'm not offering my POV to have a pissing
competition. I think that Chris' original statement about using continue
is ill founded and incorrect and I have offered reasons for it. I dont
know what you mean by "code patterns" in this respect - it seems it just
muddies the waters and takes the conversation into a totally different
realm.
Using "continue" is simply NOT an indicator of a poor design.