[Coco] GOTO and code maintainability

Lothan lothan at newsguy.com
Tue Sep 8 20:15:47 EDT 2009


I've generally considered it to be more of a "religious issue" based on 
rhetoric, as are most topics with an extreme prejudice in either direction. 
I've seen plenty of examples in my life in which a well-placed GOTO can help 
reduce complexity and/or improve readability. I've also seen plenty of 
examples of spaghetti in which some extremist tried his darndest to 
eliminate that well-placed GOTO.

Well designed code has nothing whatever to do with arguments for or against 
GOTO; in my opinion, it's more about carefully and judiciously using the 
tools available to the best of one's ability. If one gives good thought to a 
problem and finds that GOTO solves that problem, by all means use it.

I think Gene brings up an excellent point regarding the complexity of 
maintaining stack state with GOTOs, though. In general, you ought to avoid 
jumping into the middle of a code block if possible... but not to a 
religious extreme if it can't be helped. Just keep in mind that jumping into 
the middle of nested code blocks (if, for, while, do, loop, switch, ...) 
mucks with the stack and may cause some amount of unpleasantness at 
run-time. Some languages (notably C#) avoid this complexity by explicitly 
prohibiting jumping from one code block to another; e.g. labels in C# are 
scoped to the code block they're in.

--------------------------------------------------
From: "Rogelio Perea" <os9dude at gmail.com>
Sent: Tuesday, September 08, 2009 8:40 AM
To: "CoCoList for Color Computer Enthusiasts" <coco at maltedmedia.com>
Subject: Re: [Coco] GOTO and code maintainability

> To be honest, I never understood the backlash GOTO suffered from 
> structured
> language evangelists, I felt it was to be taken as the one and only
> source/cause of spaghetti code; that was the rhetoric from the uprising
> Pascal and C community back in college (mid 80's for me)... my generation
> had been brought up with TRS-80 Basic and 6800 ML assembly and that made 
> us
> all of the sudden the old guys who knew nothin' about programmin'.
>
> Same could have been said about the IF THEN ELSE construct with its 
> implied
> GOTOs, yet no one raised a ruckus over that... GOTO was the four letter 
> word
> to be wary about. Sigh...
>
> -- Rogelio
 




More information about the Coco mailing list