Click here to Skip to main content
15,902,032 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
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 
GeneralRe: Gotoless programming Pin
JamesSpencer1-Mar-12 7:23
JamesSpencer1-Mar-12 7:23 
GeneralRe: Gotoless programming Pin
Duncan Goodwin2-Mar-12 6:09
Duncan Goodwin2-Mar-12 6:09 
Anyone who has been around for a long time may remember that the GOTO-less programming controversy was laid to rest (in FORTRAN anyway) by an article published in the December 1973 issue of Datamation magazine. I kept a copy of that article all these years in my humour file as it proposed solving the problem by eliminating GOTO statements entirely and replacing them with the COME FROM statement. Here is an excerpt from the article entitled "A Linguistic Contribution to GOTO-less Programming" (Thanks to the miracle of the internet, the full article can now be found online at this link: http://www.fortran.com/come_from.html )

---------------------------------------------------------
"This statement causes control to be
transferred to the next statement (the
statement immediately following the
COME FROM) upon completion of the
designated statement.

Example:

10 J = 1
11 COME FROM 20
12 WRITE (6,40) J
STOP
13 COME FROM 10
20 J = J+2
40 FORMAT (I4)

Explanation:
In this example, J is set to I by state-
ment 10. Statement 13 then causes control to
be passed to statement 20, which sets J to 3.
Statement 11 then causes control to be passed
to statement 12, which writes the current value
of J. The STOP statement then terminates the
program."
----------------------------------------------

In all seriousness, I have not had to use a goto statement in all the code I have written since the day that structured FORTRAN replaced FORTRAN IV on our mainframes in the early 80's. And I am including all the languages I have since used up until today: C, C++, PL/1, Java, C#, VB, Lisp, APL, and JavaScript. It is almost always possible to refactor logic that appears to require a goto into an equivalent form that doesn't. If your nesting is too deep, refactor into shorter, more succinct, and readable methods. Modern IDE's make refactoring dead easy and I have made extensive use of refactoring support in Eclipse as well as Visual Studio.

But for any fans of computer history, do yourself a favour and read the entire article at the link above.

Apologies for the Canadian (ie. British) spelling of 'humour' and 'favour'. I know they are somewhat anachronistic today, but that was how I was taught.
GeneralRe: Gotoless programming Pin
Duncan Goodwin2-Mar-12 6:38
Duncan Goodwin2-Mar-12 6:38 
GeneralRe: Gotoless programming Pin
theMadCoder7-Mar-12 4:20
theMadCoder7-Mar-12 4:20 
General9000 lines of ... PinPopular
CDP180220-Feb-12 23:03
CDP180220-Feb-12 23:03 
GeneralRe: 9000 lines of ... Pin
Nagy Vilmos20-Feb-12 23:14
professionalNagy Vilmos20-Feb-12 23:14 
GeneralRe: 9000 lines of ... Pin
CDP180220-Feb-12 23:21
CDP180220-Feb-12 23:21 
JokeRe: 9000 lines of ... Pin
Sean Holm20-Feb-12 23:50
professionalSean Holm20-Feb-12 23:50 
GeneralRe: 9000 lines of ... Pin
BobJanova21-Feb-12 0:15
BobJanova21-Feb-12 0:15 
GeneralRe: 9000 lines of ... Pin
fjdiewornncalwe21-Feb-12 5:12
professionalfjdiewornncalwe21-Feb-12 5:12 
GeneralRe: 9000 lines of ... Pin
CDP180222-Feb-12 3:04
CDP180222-Feb-12 3:04 
GeneralRe: 9000 lines of ... Pin
fjdiewornncalwe22-Feb-12 3:19
professionalfjdiewornncalwe22-Feb-12 3:19 
GeneralRe: 9000 lines of ... Pin
CDP180222-Feb-12 4:35
CDP180222-Feb-12 4:35 
GeneralRe: 9000 lines of ... Pin
JackDingler28-Feb-12 5:18
JackDingler28-Feb-12 5:18 
GeneralRe: 9000 lines of ... Pin
theMadCoder7-Mar-12 4:24
theMadCoder7-Mar-12 4:24 
GeneralRe: 9000 lines of ... Pin
ekolis22-Feb-12 7:15
ekolis22-Feb-12 7:15 
GeneralRe: 9000 lines of ... Pin
Stefan_Lang22-Feb-12 3:48
Stefan_Lang22-Feb-12 3:48 
GeneralRe: 9000 lines of ... Pin
CDP180222-Feb-12 4:22
CDP180222-Feb-12 4:22 
GeneralRe: 9000 lines of ... Pin
ekolis22-Feb-12 7:18
ekolis22-Feb-12 7:18 

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.