From: Mike Nelson Date: 2006-05-20T01:15:21+09:00 Subject: Re: How to "go to" in a RUBY script . . . Leslie Viljoen wrote: > I think the great fear of having spaghetti code resulted in a bit of > an over-reaction: the universal condemnation of goto. Goto is still > sometimes simple and useful. > I couldn't agree more. I'd also add that not using goto structures doesn't help you from writing spaghetti code that much. Even using well-structured functions can become a complex mess. The whole goto issue is sort of similar to the TDD problem in my mind. The difference is there is a possible fix for the TDD problem in BDD. It's not a code problem but a problem of how the we perceive the code. We used Test Driven Design to help our development processes but we missed the point of TDD so much that we have to come up with Behavior Driven Design, which is the really same thing but is more explicit in the terminology to help us get the point of what TDD was in the first place. Back then, with the goto problem, we found that we were writing a bunch of messy and goto was the central construct that abused. So we decided that it was better to use the function construct in most cases in order to help this problem. But in our retreat of messy code we seemed to place our fear of it wholly into the goto construct itself. My guess is that this allows us to say that we can ignore a lot of that fear now as long as we don't use goto statements, which is sort of ignoring the central problem of messy code. Because of all this, it now seems that we are left with a weird superstition around the goto construct. Which is pretty odd to me because it's still a fundamental construct used on the CPU, so why not use it in the code when it helps? -- Posted via http://www.ruby-forum.com/.