|
I have had to maintain other people's code where they used the GOTO statement. There would be things like... :Tag1 (Some Stuff 1) . . . If (B = 7) Goto Tag3 If (A > 12) Goto Tag1 If (A < 13) Goto Tag2 (Some Stuff 2) . . . :Tag2 (Some Stuff 3) . . . Goto Tag1 (Some Stuff 4) . . . :Tag3 (Some Stuff 5) . . . End Of Program and I have to maintain this stuff. This is light compared to what I've seen. Is it obvious that (Some Stuff 2) will never get executed? And don't think that's the exception, in almost every one of these programs I was maintaining I would find whole blocks of code that could never get executed, and you wouldn't realize it until you traced through this spagetti to find out how it actually flows. When is the program over? Well, whenever it hits the End Of Program. So you have to go back and see that it flows from Tag 3, or did it drop through from (Some Stuff 4) ? So you start to trace (Some Stuff 4) and realize it can never be executed either! Then you see it goes to Tag3 when B = 7. Where is B set? Oh, shoot, it's set everywhere. Which part of the code sets it just before the comparison? Was it from (Some Stuff 1), or some other block of code before it jumped to 1? Do not think this is in any way an exaggeration, this is tame compared to the spagetti I had to wade thought to make a simple program modification. Something that would take me maybe 2 minutes in a structred program now takes me 2 to 3 hours. After I figured out what the program was supposed to do I would rearrange it for top down logic. By the time I was gone 2/3 of the program would be gone! Never executed code, redundant code, endless loops. Now, someone has to come in and make a change, it's a 2 minute job, not an all day affair. THAT is what is so bad about GOTO. When computers had 48k of memory total to run a program in and a 520k floppy to store data on, goto had it's place. Do as much as you can in as little as you can, otherwise, you just can't do it. But now, with our available DASD and memory, there is no need. Regards, Jim Langston Ken.Slaugh@cm-inc.com wrote: > > Go Brad, > > I've always wondered why the GOTO statement was so bad. Nobody has > ever proven it's problems, if there actually is any. It just always seems > to be just an opinion. > > Opinions are like A-Holes, everyone has one. +--- | This is the RPG/400 Mailing List! | To submit a new message, send your mail to RPG400-L@midrange.com. | To subscribe to this list send email to RPG400-L-SUB@midrange.com. | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.