Re: "Continue& quot; usage
Chris Dollin <chris.dollin@h p.comwrites:
Wierd. I see the above and it is 100% clear and concise. No scrolling
needed. No guesswork. In fact I can not think of anything better for
this.
Of course. And the scroll down to see what, if anything, is on the else
part. Already more complicated.
Immaterial. They can be. My way makes it immaterial anyway.
I guess you are trying to belittle my comments with that?
It is totally clear.
If I am not interested in this element then check the next one. What
could be easier. I suspect you have made your mind up so any more
discussion will be a waste of time.
Chris Dollin <chris.dollin@h p.comwrites:
Richard wrote:
>
>
This is exactly the kind of example that I find smelly. (Weakly
smelly, but still smelly.)
>
>Chris Dollin <chris.dollin@h p.comwrites:
>>
>>
>Actually it makes perfect sense when you have your gate condition at the
>top of the section - far easier to read, understand and maintain in many
>cases (not all of course).
>>
>while(n--){
>>
> if(complexCondi tionNotMatched( n))
> continue; /* not interested. Check the next if there is one. */
>>
> /*do processing of things we are interested in*/
>>
>}
>>
>>mdh wrote:
>>>
>>>May I ask the group this somewhat non-focused question....hav ing now
>>>seen "continue" used in some of the solutions I have worked on. ( Ex
>>>7-4 solution by Tondo and Gimpel comes to mind)
>>>Is there a good principle/s for the good usage of "continue"...or ...do
>>>any of the regular/irregular contributors have a "favorite" way in
>>>which it is particularly useful. Thanks as usual.
>>>
>>I have seen `continue` used sensibly [1] so rarely
>>that I treat any use of it
>>as a code smell
>>suggesting
>>that there is an opportunity
>>to fix the design
>>in a way that eliminates any need
>>to consider continue for that code.
>>>
>>To indicate an empty loop body
>>I find `{}` perfectly adequate
>>on those odd occasions
>>when it is needed.
>>>
>>Mind the gap.
>>>
>>[1] From my POV, natch.
>>>
>>>May I ask the group this somewhat non-focused question....hav ing now
>>>seen "continue" used in some of the solutions I have worked on. ( Ex
>>>7-4 solution by Tondo and Gimpel comes to mind)
>>>Is there a good principle/s for the good usage of "continue"...or ...do
>>>any of the regular/irregular contributors have a "favorite" way in
>>>which it is particularly useful. Thanks as usual.
>>>
>>I have seen `continue` used sensibly [1] so rarely
>>that I treat any use of it
>>as a code smell
>>suggesting
>>that there is an opportunity
>>to fix the design
>>in a way that eliminates any need
>>to consider continue for that code.
>>>
>>To indicate an empty loop body
>>I find `{}` perfectly adequate
>>on those odd occasions
>>when it is needed.
>>>
>>Mind the gap.
>>>
>>[1] From my POV, natch.
>Actually it makes perfect sense when you have your gate condition at the
>top of the section - far easier to read, understand and maintain in many
>cases (not all of course).
>>
>while(n--){
>>
> if(complexCondi tionNotMatched( n))
> continue; /* not interested. Check the next if there is one. */
>>
> /*do processing of things we are interested in*/
>>
>}
This is exactly the kind of example that I find smelly. (Weakly
smelly, but still smelly.)
needed. No guesswork. In fact I can not think of anything better for
this.
>
I would write the utterly obvious:
>
while (n--)
if (complexConditi onMatched(n))
doInterestingTh ings(n);
>
(Add layout and braces and inlined function body to taste.)
I would write the utterly obvious:
>
while (n--)
if (complexConditi onMatched(n))
doInterestingTh ings(n);
>
(Add layout and braces and inlined function body to taste.)
part. Already more complicated.
>
>
No, we don't. We just look; functions are not /that/ big, especially
>Now we could invert the test but then we need to scroll down to the end
>of the function to be see what else happens after the block.
>of the function to be see what else happens after the block.
No, we don't. We just look; functions are not /that/ big, especially
nowadays, and editors are not that feeble, so I'm told.
>
>
It's not a clear statement of intent; or, more exactly, it's not as
clear a statement as one could write with similar effort.
>Seems clear, maintainable and decent design to me. I fail to see how it
>could be construed as "bad" in any shape or form.
>could be construed as "bad" in any shape or form.
It's not a clear statement of intent; or, more exactly, it's not as
clear a statement as one could write with similar effort.
If I am not interested in this element then check the next one. What
could be easier. I suspect you have made your mind up so any more
discussion will be a waste of time.
Comment