Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Cursor Question

Re: Cursor Question

From: Kenneth C Stahl <kstahl_at_lucent.com>
Date: Tue, 22 Jun 1999 08:53:25 -0400
Message-ID: <376F8745.DDDD5708@lucent.com>


The argument is absurd. The use of GOTO does not automatically equate to spaghetti logic. If you were to read any of my programs where I have used GOTO you would never have any doubts at all about the flow of execution or my intent. On the other hand I have read (and unfortunately had to maintain) a lot of programs written by programmers who are so adamant about not using GOTO that their code is unreadable through incredible levels of selection logic. Of course, these programmers also tend to be the ones who write functions/procedures that span hundreds of lines of codes, who never properly format their code and who never use comments. But, by god, they never use GOTO.

On the other hand, whereever possible I limit my functions to less than 60 lines, I am obsessive about formatting, use comments to explain what I'm doing and occasionally I use a GOTO when it makes sense to do so. I obviously must be doing something right - I've never had a maintenance programmer complain that they cannot understand my code because of the presence of GOTO.

I wonder what it takes to be an "old programmer" who "cringes" at GOTO? I've been a software developer since 1981. I've also made a fairly decent living at this profession, so I'm quite a bit past the "wannabe" stage. You see, programming is not just a bunch of computer-science-weenie-theory-crap, it is work that I do on behalf of my employer to provide the best possible sofware within the constraints of time, money and practicality. If I end up using a GOTO to solve a problem I do it because it makes sense within the context of what my employer is asking me to do. I don't seek out situations for the purpose of using a GOTO, but I don't sit with a project on my desk for weeks at a time just because I want to ensure that I never use a GOTO in the code. I get the job done and then I move on. My employers tend to like it that way.

Sorry for the "religious" discussion, but I've spent a long time at this job and am not going to buy into some theoretical notion that something is either good or bad because it is part of programming lore.

> And that is the problem with many of these so-called programmers - they can
> not solve a problem and the resort to using the GOTO statement. Ever tried
> to maintain spaghetti logic? Which is why I have a very stong distaste for a
> GOTO statement. And I can not recall ever having to resort to using GOTO
> statements myself.

> >Fortunately Stroustrup understood this problem when he developed C++ - you
> >realize, of course, that a throw-catch sequence is the same as a GOTO - it
> just
> >doesn't use the GOTO word, that's all. In fact, exceptions in C++ can be
> used
> >in ways that far exceed that which GOTO can since GOTO in C is limited to
> the
> >scope of a single function.
>
> True. Ditto for Delphi too. But then this is specifically aimed at handling
> exceptions and not a logic crutch for wanna-be programmers.
>
> >Also, in PL/SQL the EXIT statement is merely a synonym for GOTO.
>
> Not really true - a GOTO is used to branch/jump to another section of logic.
> An EXIT indicates that the current code block (procedure/method) is
> unconditionally terminated. Sure, an EXIT can be described as a GOTO
> statement that jumps to the terminator of the current code block, but by the
> same token you can see an EXIT statement as just that. Exit the current code
> block here and now - RETF instead of a JMP if you get my meaning... :-)
>
> The problem with the GOTO statement is not what it does - of course you need
> to be able to branch the execution of code. You are right - in the "right
> situation" the use of the GOTO statement may be justified. I think that this
> concept of "bad GOTO, bad!" is simply a method to get would be programmers
> to realise that to solve a complex programming problems requires the use of
> gray matter and not GOTO statements. And whenever one of us "old
> programmers" see a GOTO statement, we do cringe, as our first reaction is
> that the programmer got himself/herself into a logic mess and now needs to
> use a GOTO statement to het out of trouble.
>
Received on Tue Jun 22 1999 - 07:53:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US