Re: how do people feel about exit function from loop



What you're trying to do there is find situations that are suited to not
using exit for.

That's usually how one makes a point.

I care. If someone goes to extensive lengths to avoid using exit function
or exit for then the code becomes less readable.

Only to someone who's not used to that coding style. For myself, I find it
no more or less readable either way. I just don't necessarily know where my
exit points are when using Exit For; when not using it, however, I know that
any code not bracketed by If's and the like WILL run for each iteration
until the conditions are satisfied.

The example given by the OP was significantly more difficult to read and
it was a very simple loop.

The only thing that made it more difficult to read for me was the length of
his variable names.

In more complex loops it could become quite difficult to write and
maintain and there really is no benefit except to adhere to some self made
preconception of the programmer.

At least one benefit was listed above. As for being difficult to write and
maintain in more complex loops, I generally don't find it makes any
difference whatsoever. You get the same one or two extra lines of overhead
code due to the difference in style, and the rest of your loop stays the
same.

By the same token, one who's even more immersed in structured programming
than I am might well find it more difficult to figure out what's going on
with the Exit For strategy. When you get right down to it, pretty much any
argument either of us makes for or against can be applied in reverse as
well. The simple fact is that some people don't like one method or the
other, as it offends their sensibilities, but in reality, there's points for
and against each method. In the end, any programmer thinking of taking over
someone else's project should expect differences in coding style that they
may find more difficult to read, not being used to it, but should be
well-enough versed in all methods not to care significantly unless there's
something TRULY awful about the code (like iterating instead of looping, for
instance).



Rob


.



Relevant Pages

  • Re: Infinite Loops and Explicit Exits
    ... > CS> One of these proposals relaxes the current restriction that an EXIT ... > termination of the loop is not visible at that point. ... > terminating condition is visible in that context. ... > You now want to allow this remote procedure, ...
    (comp.lang.cobol)
  • Re: Exit Do
    ... I've been instructed by a dot net / asp programmer that Exit Do is ... I am using nested loops and need to exit out of one loop into ... Code Stage B ...
    (microsoft.public.scripting.vbscript)
  • Re: for loops
    ... I personally would never use a FOR ENDFOR loop for something that I do not ... and such constructs lets one think the programmer wasnt able to create ... > regardless of which programming-language i worked in. ... > Using EXIT breaks the structured program-flow. ...
    (microsoft.public.fox.programmer.exchange)
  • Re: Houston-related rants was Re: forced merges/inside lane merges/AASHTO "tapered merges"
    ... >> Are you sure about the North Loop and I-45? ... >> in particular the westbound exit for Fondren/Gessner. ... How could HCTRA put an exit ramp for eastbound ... and the West Houston Center Blvd exit still shows Old Westheimer ...
    (misc.transport.road)
  • Re: Exit Do
    ... I've been instructed by a dot net / asp programmer that Exit Do is ... I am using nested loops and need to exit out of one loop into ... Code Stage B ... likely to lead to bugs and readability problems. ...
    (microsoft.public.scripting.vbscript)