Thursday, December 24, 2009

Why is it that some programmers doesn't recommend the use of goto - statement in programming?

See it is better explained here : http://en.wikipedia.org/wiki/GotoWhy is it that some programmers doesn't recommend the use of goto - statement in programming?
The bottom line is, goto doesn't return your program from where you send it if you use it.





A procedure or subroutine keeps track of where you were in the program and sends you back there when you are done. A function does the same, except it provides you with some value you may not have had before. What is the advantage with that? With goto the temptation is to create spaghetti code. That is, since you have to keep track of where in the program you are, the temptation is to write code that is functionally identical in more than one place, rather than to keep track of where the calling code is from and returning it -- in fact with goto it is easier to repeat code and send it somewhere else each time. But the real problem is that is you are supposed to read and understand the WHOLE THING, not just one element at a time. Using routines you return from makes the code more understandable, it requires less code loaded into memory, and it makes efficiency possible. That structured programming, as it's called got its start when mainframes had less power than many scientific calculators you can get for $20 today, doesn't make it any less a good idea.Why is it that some programmers doesn't recommend the use of goto - statement in programming?
Because they think other programmers are too stupid/inexperienced to use them correctly. 99% of the time, they're right.
There are supposed to be better ways. It also said that users of goto statements haven't done their homework. At least those are things that many veteran programmers say.
Using goto statements can make your program hard to read and maintain.
  • blonde highlight
  • oil offshore
  • printer ink
  • printer ink
  • No comments:

    Post a Comment