[AccessD] Learning .Net -- PHP Instead?

jwcolby jwcolby at colbyconsulting.com
Wed Jun 24 10:33:51 CDT 2009


Charlotte,

 > Structured programming suggests you instead design the code so there is no reason to use a GOTO.

I have to say that while I agree in theory I disagree in practice.  I find occasions where I want to 
test something at the beginning and just abort if found.  Rather than add a new if/else level of 
indentation I just Goto ExitPoint.  I don't find that a horrendous practice.

I think the "ban on goto" comes from the spaghetti code that we all knew and loved back in the day. 
  There is (almost) no excuse for line numbers, or labels and code to GoTo the label.  It can ALWAYS 
be worked around, though there are very rare occasions where it actually makes cleaner code to do a 
GoTo Label.

A funny story...

Back in the early 80s I was a bench technician at Megatek Corp in Sorrento Valley (San Diego).  My 
workstation was a Data General mini with 16 KWords of memory.  Somewhere I found a Star Trek game 
written in Basic, but it wouldn't run because the interpreter and the game wouldn't all fit in 
memory at the same time.

I printed the Basic source code out on the old yellow teletype roll paper, laid it on the floor and 
started studying it.  In that version of Basic there were no functions or subroutines, so EVERYTHING 
was a GoTo.  I started tracing the GoTos with an ink pen.

I got a true appreciation for the term spaghetti code.  I never did get the code to run.

I don't write spaghetti code but I probably do use a GoTo once or twice a year, when it makes the 
code more understandable.

John W. Colby
www.ColbyConsulting.com


Charlotte Foust wrote:
> Structured programming suggests you instead design the code so there is
> no reason to use a GOTO.  If you hit a condition in a particular branch,
> the code naturally arrives at the exitpoint.  Very clean concept, that.
> 
> Charlotte Foust 




More information about the AccessD mailing list