views:

284

answers:

5

Possible Duplicates:
Why is goto poor practise?
GOTO still considered harmful?

Hi,

I have read in many book that using goto is bad programming practice, why is it so?

thanks Yogesh

+3  A: 

1 reason is that it produces spaghetti code that is hard to follow.

AndyC
+4  A: 

Goto considered harmful

kgiannakakis
Dijkstra knows his stuff :)
Filip Ekberg
+1  A: 

using goto is not bad as long as you know for what purpose you are using. use judiciously.

aJ
E.g. for breaking out of nested loops. That's pretty much the single justified case for it nowadays.
yk4ever
A: 

Original article by Edsger Dijkstra: http://userweb.cs.utexas.edu/users/EWD/ewd02xx/EWD215.PDF

yk4ever
@yk4ever, this was already posted by @kgiannakakis
Filip Ekberg
+1  A: 

Dijkstra and Wirth, proponents of structured programming, have critisized the use of goto, and people started to think that goto is plain evil, although it isn't always a case. There are situations when use of goto results in cleaner code, like in error handling.

qrdl
Using "goto" is just a low level function call ;)
Filip Ekberg