The 'goto' statement

I understand that this can be a useful and simple way of cutting out of loops and functions etc, but can't help notice that their are other more 'proper' methods like the break; or use of a function, does the goto statement have and bad implications, because my experiences with them have been fine?
It's looked down on because it can easily lead to "spaghetti code" if overused. There are some situations where it is justified, but by and large you should use the 'proper' methods provided by the language.
Some FlowChart->C/C++ generators make heavy use of goto statements, which is a valid use if you're aiming for simplicity. Just be careful about labels not conforming to scope as everything else does.
also be aware that techniques that seem to work well for code snippets (eg goto) can fail badly when you scale your app

for example, another technique similar to a goto that's frowned upon is returning from more than one spot in a method/function; however, if your method or function is tiny, it makes little difference; but as it gets say, over a page long (which I almost always refactor to be smaller anyways), multiple-returns can become a source for bugs

but like all things, exercise good judgment and you should be fine
Topic archived. No new replies allowed.