Click here to Skip to main content
15,891,976 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: I just used a goto! Pin
Gerardo Orozco21-Jun-19 4:34
Gerardo Orozco21-Jun-19 4:34 
GeneralRe: I just used a goto! Pin
englebart21-Jun-19 4:52
professionalenglebart21-Jun-19 4:52 
GeneralRe: I just used a goto! Pin
Super Lloyd21-Jun-19 5:27
Super Lloyd21-Jun-19 5:27 
GeneralRe: I just used a goto! Pin
sasadler21-Jun-19 6:28
sasadler21-Jun-19 6:28 
GeneralRe: I just used a goto! Pin
Michael Breeden21-Jun-19 8:29
Michael Breeden21-Jun-19 8:29 
GeneralRe: I just used a goto! Pin
gggustafson21-Jun-19 10:12
mvagggustafson21-Jun-19 10:12 
GeneralRe: I just used a goto! Pin
Member 916705723-Jun-19 23:05
Member 916705723-Jun-19 23:05 
GeneralRe: I just used a goto! Pin
Matt McGuire24-Jun-19 7:18
professionalMatt McGuire24-Jun-19 7:18 
there's nothing inherently wrong with goto, it's just another tool that works just like OP jump codes on a processor, jumping the running process to another memory location.

It's quite handy too when the code structure gets nested too deep or you can't use recursion; it has it's place, and can keep the code more readable when done right.

Unfortunately before structured programming came around that's all you had to move around, this was quite common in early version of BASICA or GW, where using subroutines wasn't as common. all this turned in to spaghetti code, earning procedural languages like Basic a bad rep (that stuck). the developers that grew up on these early languages unfortunately carried this forward using goto's everywhere, making it a nightmare to debug when something went wrong.

My personal rules for goto's:
*keep the function as short as possible so you can see the GOTO and the LABEL on the screen at the same time.
*never use more than one redirection, ie multiple goto's to one label is fine if absolutely necessary, but never ever use multiple goto's and multiple labels, that just too much jumping around, and gets hard to follow.
*does the code look cleaner and easier to follow with a goto or using check values with more if's?
*can the process be restructured to avoid the deep nesting that caused a goto to be used in the first place.
*keep the code as simple as possible.

That being said, I've used goto maybe 5-10 times in my 20+ years developing, and I don't regret it.
GeneralCCC 20/6 Pin
PeejayAdams19-Jun-19 22:12
PeejayAdams19-Jun-19 22:12 
GeneralRe: CCC 20/6 Pin
pkfox19-Jun-19 23:30
professionalpkfox19-Jun-19 23:30 
GeneralRe: CCC 20/6 - SOLVED Pin
PeejayAdams19-Jun-19 23:35
PeejayAdams19-Jun-19 23:35 
GeneralRe: CCC 20/6 - SOLVED Pin
pkfox19-Jun-19 23:38
professionalpkfox19-Jun-19 23:38 
GeneralBug Of The Year, aka Booty! :D PinPopular
Super Lloyd19-Jun-19 16:40
Super Lloyd19-Jun-19 16:40 
GeneralRe: Bug Of The Year, aka Booty! :D Pin
Brisingr Aerowing19-Jun-19 17:24
professionalBrisingr Aerowing19-Jun-19 17:24 
GeneralRe: Bug Of The Year, aka Booty! :D Pin
Johnny J.19-Jun-19 19:30
professionalJohnny J.19-Jun-19 19:30 
GeneralRe: Bug Of The Year, aka Booty! :D Pin
the goat in your machine19-Jun-19 19:41
the goat in your machine19-Jun-19 19:41 
GeneralRe: Bug Of The Year, aka Booty! :D Pin
dan!sh 19-Jun-19 23:24
professional dan!sh 19-Jun-19 23:24 
GeneralRe: Bug Of The Year, aka Booty! :D Pin
Super Lloyd20-Jun-19 0:09
Super Lloyd20-Jun-19 0:09 
GeneralRe: Bug Of The Year, aka Booty! :D Pin
Sander Rossel20-Jun-19 1:41
professionalSander Rossel20-Jun-19 1:41 
GeneralRe: Bug Of The Year, aka Booty! :D Pin
Super Lloyd20-Jun-19 2:34
Super Lloyd20-Jun-19 2:34 
GeneralRe: Bug Of The Year, aka Booty! :D Pin
obermd21-Jun-19 3:36
obermd21-Jun-19 3:36 
GeneralRe: Bug Of The Year, aka Booty! :D PinPopular
Chris Maunder20-Jun-19 8:10
cofounderChris Maunder20-Jun-19 8:10 
GeneralMini CCCs 100 Pin
Tim Deveaux19-Jun-19 16:16
Tim Deveaux19-Jun-19 16:16 
GeneralRe: Mini CCCs 100 Pin
OriginalGriff19-Jun-19 20:17
mveOriginalGriff19-Jun-19 20:17 
GeneralRe: Mini CCCs 100 Pin
pkfox19-Jun-19 23:40
professionalpkfox19-Jun-19 23:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.