Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Coding Styles
#17
Some folks are vehemently against GOTO statements.   I tend to find them to be the most elegant, and simple solution in many cases.

Are you nestled 12 loops deep, within countless IF and SELECT and other branching statements, and then suddenly you find yourself done with everything that single branch of conditions can do?

GOTO Finished_Processing


Wooooo....  Now, WTF is any simpler than that to understand?  It leaps you out of all those conditions/loops/branches and ...  by golly, it takes you... to the beginning of processing!   Tongue   Actually, I would think that anyone who speaks the language could tell you exactly where that GOTO is going to take you -- to the end of the Processing code segment!

GOTO Start   <-- Gee willikers, this one is hard to understand
GOTO RedoInput   <---  Gosh, I'd never know where this is going to send me, or what its purpose is
GOTO PrintResults  <---  Umm...  I'm guessing this is where we ask for a lot of user input.  Right??


The most important thing with GOTOs is that the LABEL they link to has to be descriptive, and that they don't immediately branch off some friggin place else, like some of the older BAS programs used to.   NOBODY can puzzle out that spaghetti crap!

10 GOTO 20
20 GOTO 40
30 GOT0 50
40 GOTO 30
50 GOTO 60
60 ON x GOTO 10, 20, 30, 40, 50
70 GOTO 0

WTF????

Numeric labels are a FAIL with GOTO.  A GOTO needs a very descriptive and unique label to help understand and state its purpose.
A GOTO should never directly lead into another GOTO.  That's the stupidest thing in the world.  Just have the first GOTO go directly where it needs to be, without leaping through a dozen hoops with middle men!

Gotos really aren't bad in use when coding.  They're there for a simple, and powerful purpose.

They just really, REALLY, REALLY-REALLY suck bad when they're misused!
Reply


Messages In This Thread
Coding Styles - by Pete - 08-09-2024, 03:09 PM
RE: Coding Styles - by SpriggsySpriggs - 08-09-2024, 03:21 PM
RE: Coding Styles - by TerryRitchie - 08-09-2024, 05:29 PM
RE: Coding Styles - by Pete - 08-09-2024, 03:54 PM
RE: Coding Styles - by bplus - 08-09-2024, 04:03 PM
RE: Coding Styles - by SMcNeill - 08-09-2024, 09:03 PM
RE: Coding Styles - by Pete - 08-09-2024, 04:16 PM
RE: Coding Styles - by SpriggsySpriggs - 08-09-2024, 06:40 PM
RE: Coding Styles - by TerryRitchie - 08-09-2024, 07:52 PM
RE: Coding Styles - by Jack - 08-09-2024, 07:10 PM
RE: Coding Styles - by Jack - 08-09-2024, 07:19 PM
RE: Coding Styles - by Kernelpanic - 08-09-2024, 10:29 PM
RE: Coding Styles - by CharlieJV - 08-09-2024, 10:56 PM
RE: Coding Styles - by Kernelpanic - 08-09-2024, 11:21 PM
RE: Coding Styles - by CharlieJV - 08-09-2024, 11:27 PM
RE: Coding Styles - by Pete - 08-10-2024, 03:46 AM
RE: Coding Styles - by SMcNeill - 08-10-2024, 04:55 AM
RE: Coding Styles - by JRace - 08-10-2024, 09:41 AM
RE: Coding Styles - by SMcNeill - 08-10-2024, 10:43 AM
RE: Coding Styles - by OldMoses - 08-10-2024, 12:08 PM
RE: Coding Styles - by CharlieJV - 08-10-2024, 02:11 PM
RE: Coding Styles - by Pete - 08-10-2024, 02:55 PM
RE: Coding Styles - by bplus - 08-10-2024, 03:19 PM
RE: Coding Styles - by SMcNeill - 08-10-2024, 03:41 PM
RE: Coding Styles - by Pete - 08-10-2024, 04:28 PM
RE: Coding Styles - by SMcNeill - 08-10-2024, 11:08 PM
RE: Coding Styles - by Kernelpanic - 08-10-2024, 06:00 PM
RE: Coding Styles - by Pete - 08-10-2024, 07:30 PM
RE: Coding Styles - by TerryRitchie - 08-10-2024, 07:53 PM
RE: Coding Styles - by TempodiBasic - 08-11-2024, 12:46 PM
RE: Coding Styles - by Pete - 08-11-2024, 06:45 PM
RE: Coding Styles - by Kernelpanic - 08-19-2024, 06:35 PM
RE: Coding Styles - by quickbasic - 09-04-2024, 06:09 PM
RE: Coding Styles - by dano - 09-09-2024, 12:46 AM



Users browsing this thread: 29 Guest(s)