+ 2

Why using goto statement is not considered as a good programming practice?????

17th May 2019, 9:02 AM
Ritika Joshi
Ritika Joshi - avatar
4 Antworten
+ 7
Sweet Tech Because they lead to spaghetti code( https://en.m.wikipedia.org/wiki/Spaghetti_code ). In the past programming languages didn't have while() if() etc, and programmers used goto to make up the logic of their programs. It lead to an unmaintainable mess. That's why the CS gods created functions conditionals and loops. Structuredprogramming was a revolution at the time. goto's are appropriate in a few places, such as for jumping out of nested loops. source: https://stackoverflow.com/questions/3517726/what-is-wrong-with-using-goto you can found also a funny meme of goto on php docs: https://www.php.net/manual/en/control-structures.goto.php I hope I was helpful
17th May 2019, 9:13 AM
Alessio Benvenuti
Alessio Benvenuti - avatar
+ 3
It leads to nasty looking code and it's just cleaner and more appropriate to use the other methods of "moving around" code that is built into the language. There are rare occasions for using a goto statement
17th May 2019, 9:12 AM
Earl Chukwu
Earl Chukwu - avatar
+ 3
It is considered ARCHAIC 😡
19th May 2019, 4:48 AM
Sanjay Kamath
Sanjay Kamath - avatar
+ 2
Because you can't go back to where you started. If you are at line 10 and execute goto to line 50 then you can't backtrace your way to line 10. Your program go ahead from line 50. It's Simple
19th May 2019, 6:36 AM
Rhythm Sehgal
Rhythm Sehgal - avatar