Click here to Skip to main content
15,903,385 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Gotoless programming Pin
DerekT-P28-Feb-12 1:36
professionalDerekT-P28-Feb-12 1:36 
GeneralRe: Gotoless programming Pin
Kirk Wood28-Feb-12 1:46
Kirk Wood28-Feb-12 1:46 
GeneralRe: Gotoless programming Pin
Jonathan C Dickinson28-Feb-12 1:56
Jonathan C Dickinson28-Feb-12 1:56 
GeneralRe: Gotoless programming Pin
Kirk Wood28-Feb-12 1:51
Kirk Wood28-Feb-12 1:51 
GeneralRe: Gotoless programming Pin
Anthony Appleyard27-Feb-12 19:24
Anthony Appleyard27-Feb-12 19:24 
GeneralRe: Gotoless programming Pin
GuyThiebaut27-Feb-12 20:39
professionalGuyThiebaut27-Feb-12 20:39 
GeneralRe: Gotoless programming Pin
Stefan_Lang27-Feb-12 22:02
Stefan_Lang27-Feb-12 22:02 
GeneralRe: Gotoless programming Pin
bigbadben27-Feb-12 22:57
bigbadben27-Feb-12 22:57 
The good old goto debate. A goto is a bit like telling the computer that I don't want you to proceed to the next line of code, instead make some other line the next thing to execute. And we do that all the time: exit for, exit do, if some condition goto next line otherwise goto some other line. While some condition go into first line of loop block otherwise goto past the end of the loop block. And then, it all eventually becomes machine code / opcodes, and all of these become some kind of jump instruction, which is basically a goto. So for all you people out there that think that your code has no gotos, I can assure you the CPU is doing jump instructions left, right and centre as YOUR code runs in the CPU. Now please don't tell me that your code is somehow bypassing the CPU.

The reason this myth exists is that those early versions of BASIC had line numbers for each statement. And you would code "GOTO 760". Problem was when you inserted lines and made 760 line 761 or whatever but didn't go and update everything pointing to 760. And so this caused problems and bugs. Let's move on. We have alphabetic statement labels (used all the time in assembly language by the way), so you can now "Goto SomeLabelThatHasAMeaningfulNameThatWontBeRenumbered" and the problem is gone. Use goto freely, it's OK. I do it. It gets me out of deep nested rules and condition logic where I have established something I needed to establish. Yes there are always other ways to achieve the same result, but no - they are not always better or more elegant. And now it is time for me to go to bed.
GeneralRe: Gotoless programming Pin
glennPattonWork328-Feb-12 0:24
professionalglennPattonWork328-Feb-12 0:24 
GeneralRe: Gotoless programming Pin
BobJanova28-Feb-12 1:34
BobJanova28-Feb-12 1:34 
GeneralRe: Gotoless programming Pin
JackDingler28-Feb-12 2:39
JackDingler28-Feb-12 2:39 
GeneralRe: Gotoless programming Pin
bigbadben1-Mar-12 1:38
bigbadben1-Mar-12 1:38 
GeneralRe: Gotoless programming Pin
bigbadben29-Feb-12 1:13
bigbadben29-Feb-12 1:13 
GeneralRe: Gotoless programming Pin
Fran Porretto28-Feb-12 1:09
Fran Porretto28-Feb-12 1:09 
GeneralRe: Gotoless programming Pin
Reelix28-Feb-12 1:12
Reelix28-Feb-12 1:12 
GeneralRe: Gotoless programming Pin
JackDingler28-Feb-12 2:28
JackDingler28-Feb-12 2:28 
GeneralRe: Gotoless programming Pin
JackDingler28-Feb-12 2:36
JackDingler28-Feb-12 2:36 
GeneralRe: Gotoless programming Pin
reilly9628-Feb-12 2:39
reilly9628-Feb-12 2:39 
GeneralRe: Gotoless programming Pin
Member 797506328-Feb-12 3:41
Member 797506328-Feb-12 3:41 
GeneralRe: Gotoless programming Pin
JackDingler28-Feb-12 5:11
JackDingler28-Feb-12 5:11 
GeneralRe: Gotoless programming Pin
Charlie Ehler28-Feb-12 5:29
Charlie Ehler28-Feb-12 5:29 
GeneralRe: Gotoless programming Pin
SeattleC++28-Feb-12 6:21
SeattleC++28-Feb-12 6:21 
GeneralRe: Gotoless programming Pin
Member 205300628-Feb-12 6:35
Member 205300628-Feb-12 6:35 
GeneralRe: Gotoless programming Pin
TNCaver28-Feb-12 10:44
TNCaver28-Feb-12 10:44 
GeneralRe: Gotoless programming Pin
Plamen Dragiyski28-Feb-12 11:30
professionalPlamen Dragiyski28-Feb-12 11:30 

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.