Does anyone have a good example/sample of "goto" spaghetti code? [closed]
- by ArtB
I've read a lot about how GoTo was considered harmful and removed for other control structures that were more intuitive. Does anyone have a good example / sample of goto spaghetti code? Preferrably, the sample code should be difficult to follow, but realtively easy when rewritten into more conventional control structures.
I know I could try to write you some of my own, but I've never really used goto and don't think I could due justice to the headaches its abuse can lead to.
I want this for didactic purposes to train junior developers on what to avoid. Mainly, to point to illustrate how OOP is taking the same idea to next logical consequence.
EDIT: by good example I mean code that is terrible to read and abuses it, rather than code that uses goto for reasonable optimization