Click here to Skip to main content
15,912,756 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: goto statement Pin
Bill_Hallahan11-Nov-13 13:51
Bill_Hallahan11-Nov-13 13:51 
GeneralRe: goto statement Pin
Rob Grainger12-Nov-13 2:00
Rob Grainger12-Nov-13 2:00 
GeneralRe: goto statement Pin
Tarek Elqusi10-Nov-13 6:53
professionalTarek Elqusi10-Nov-13 6:53 
GeneralRe: goto statement Pin
Marc Clifton10-Nov-13 9:58
mvaMarc Clifton10-Nov-13 9:58 
GeneralRe: goto statement Pin
Joe Woodbury10-Nov-13 10:14
professionalJoe Woodbury10-Nov-13 10:14 
GeneralRe: goto statement Pin
Christian Graus10-Nov-13 12:01
protectorChristian Graus10-Nov-13 12:01 
GeneralRe: goto statement Pin
Member 1008817110-Nov-13 12:55
Member 1008817110-Nov-13 12:55 
GeneralRe: goto statement Pin
Stefan_Lang11-Nov-13 1:42
Stefan_Lang11-Nov-13 1:42 
It's often hard to understand the reasons if all you do is look at the code you've just written. You have to "look" at the code that it will grow into after a year or more of maintaining and extending that code however!

I've seen some huge 15-20 year old functions with several hundreds or even thousands of lines of code. After so many years, I could still guess the general shape and design of these functions when they were first written, and at that time, using goto was neither looked down upon quite as much, nor did it seem unreasonable in that particular piece of code. Over the years however, tons of features were added who required additional blocks of code; dozens of corner cases were detected that needed to be treated separately; and at least half a dozen developers added their differing visions of how the code should be formatted and designed.

One of the things I tried over the years is split up that code into smaller, better maintainable chunks, but I've found there is no easy way to ensure this won't break the multitude of corner cases handled by this code. I could move some of it into initialization functions, and extract a few of the special feature code blocks. But it was nigh impossible to disentangle the mass of conditional code and goto statements (few as there were) while ensuring that the code would behave exactly like it did before. With none of the original programmers around to help determine what exactly the code was supposed to do, breaking it was too high a risk to take.

I'm not saying that the goto statements were the sole reason for the sorry, unmaintainable state of the code, but they were the main reason why I was unable to transform it into something maintainable!


tl;dr:
If all you do is write short lived functions and programs then use goto at your hearts desire. But if that code that you're writing will go into a professional application that may live on and be maintained and exxtended for many years, then you better think ahead and don't introduce a legacy that is hard to bear and harder to kill!
GeneralRe: goto statement Pin
vl211-Nov-13 8:01
vl211-Nov-13 8:01 
GeneralRe: goto statement Pin
Stefan_Lang12-Nov-13 1:15
Stefan_Lang12-Nov-13 1:15 
GeneralRe: goto statement Pin
vl212-Nov-13 1:30
vl212-Nov-13 1:30 
GeneralRe: goto statement Pin
werinus12-Nov-13 1:34
werinus12-Nov-13 1:34 
GeneralRe: goto statement Pin
vl212-Nov-13 1:45
vl212-Nov-13 1:45 
GeneralRe: goto statement Pin
werinus12-Nov-13 2:36
werinus12-Nov-13 2:36 
GeneralRe: goto statement Pin
jschell12-Nov-13 9:44
jschell12-Nov-13 9:44 
GeneralRe: goto statement Pin
Bill_Hallahan12-Nov-13 13:04
Bill_Hallahan12-Nov-13 13:04 
GeneralRe: goto statement Pin
jschell13-Nov-13 9:30
jschell13-Nov-13 9:30 
GeneralRe: goto statement Pin
Bill_Hallahan13-Nov-13 17:23
Bill_Hallahan13-Nov-13 17:23 
GeneralRe: goto statement Pin
jschell14-Nov-13 7:50
jschell14-Nov-13 7:50 
GeneralRe: goto statement Pin
Bill_Hallahan14-Nov-13 14:02
Bill_Hallahan14-Nov-13 14:02 
GeneralRe: goto statement Pin
jschell12-Nov-13 9:46
jschell12-Nov-13 9:46 
GeneralRe: goto statement Pin
Bill_Hallahan12-Nov-13 13:25
Bill_Hallahan12-Nov-13 13:25 
GeneralRe: goto statement Pin
jschell13-Nov-13 9:49
jschell13-Nov-13 9:49 
GeneralRe: goto statement Pin
Stefan_Lang12-Nov-13 20:50
Stefan_Lang12-Nov-13 20:50 
GeneralRe: goto statement Pin
Bill_Hallahan12-Nov-13 12:32
Bill_Hallahan12-Nov-13 12:32 

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.