12-07-2005, 08:16 PM
GOTO can always be substituted by a structured block. Most of the time, it's better not to use it 'cause you get a more readable code, specially if you are working with someone else. It's just good practice.
Sometimes, a GOTO comes handy to do an optimization, but if you are placing it as a patch you better revise your code. This is just an advice: it's better to rework an algorithm than patching it - spaghetti is easy to produce and can be hard to debug.
GOSUB is an absolute no-no. It doesn't have ANY advantages over structured SUBs or FUNCTIONs. Absolutely none. Why using a messy solution when you have a clean one, which also allows more stuff to be done?
I've always said that GOTO is great if you know what you are doing. Seriously, don't take this as a leet discuss, 'cause it isn't. It's just me giving advice. I've been coding for ages, and I've had to fight with a 200 lines-long spaghetti function just to find that I missed a very simple detail. If I would have had the function correctly structured, just a few watches would have made it to discover the bug.
So Aga wrote it perfectly some time ago: GOTO is like chocolate :lol:
Sometimes, a GOTO comes handy to do an optimization, but if you are placing it as a patch you better revise your code. This is just an advice: it's better to rework an algorithm than patching it - spaghetti is easy to produce and can be hard to debug.
GOSUB is an absolute no-no. It doesn't have ANY advantages over structured SUBs or FUNCTIONs. Absolutely none. Why using a messy solution when you have a clean one, which also allows more stuff to be done?
I've always said that GOTO is great if you know what you are doing. Seriously, don't take this as a leet discuss, 'cause it isn't. It's just me giving advice. I've been coding for ages, and I've had to fight with a 200 lines-long spaghetti function just to find that I missed a very simple detail. If I would have had the function correctly structured, just a few watches would have made it to discover the bug.
So Aga wrote it perfectly some time ago: GOTO is like chocolate :lol:
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i