Very true. I'd add that not only is it bad practice to have a GoTo too
far from the label, it is just as bad to have too many lines of code
within an if, loop, do or whatever statement. If the top and bottom of
the code are close enough to be enclosed in a do loop the goto wouldn't
be a problem.
Also lets not forget what others have pointed out as well. Proper
naming is critical in anything. GoTo GetOutOfhere Now wouldn't be as
nice as GoTo BottomOfContinu eLoop assuming I'm using Do, While Continue
as the loop. Heck for that matter Continue is a bad choice of names in
most situations. It'd be better to use Do, While GetNewShippingR ecords
or something. Except that Continue is easily readable and
understandable in this specific app.
I'd further mention, and it's a pet peeve of mine, that I've seen these
little self contained boxes used to the point that they make code
unreadable. Some folks, and I'm not insinuating your one of them, use
them to such a point that he main code has nothing in it but calls and
then you find all it does is call others. Your jumping all over the
place to see what the next subroutine does and it becomes its own form
of spaghetti code. If you don't have to call a routine but from one
place you might not need to put it in a routine. Might, I said.
Sometimes it's good of course, like to remove a huge section of distinct
code to keep routines short enough to read.
Tim Ferguson wrote:
cj <cj@nospam.nosp am> wrote in news:et******** ******@TK2MSFTN GP12.phx.gbl:
Strangely next to
the non existent loop/continue statement goto would seem to create the
most readable and compact code.
Yebbut, Nobbut, Yebbut, Nobbut Yeah, you see... it's all about how far the
Goto GetOutOfHereNow is from the :GetOutOfHereNo w. In many implementations
they end up a long way away, and it's the code-maintainer that comes along
later and doesn't spot it.
For my money, structured programming is all about putting code into little
self-contained boxes, and any path that suddenly arrives at another point
with several different possibilities for variables that have been
initialised or not, files that have been opened or closed or not, etc etc
is asking for trouble. YMMV of course.
All the best
Tim F