Nothing riles up programmers more than a good "goto" discussion as evidenced by today's daily WTF [0]. I sometimes use labels in Java to simplify code.. every now and then that produces the following discussion;
someone: "Hey, that's a goto! You can't use a goto!"
me: "why not"
someone: "they're evil!"
me: "why?" [1]
someone: "Everyone knows that?"
me: "Okay, I must be stupid, why is this bad?"
someone: *mumble* *mumble* *run away*
Perhaps that wasn't verbatim, but it gets the idea across. Often, programmers will scream about something they don't completely understand [2]. I think the best argument against such knee-jerk reactions I've ever seen went something like this..
me: "would you use a return statement in a middle of the method?"
someone: "oh sure! I do that all the time, makes flow easier!" [3]
me: "How about something like this:"
public void someMethod()
{
if(something != something_else)
{
goto end;
}
else
{
do_something_else;
}
end:
}
someone: "err.."
Of course the above was not Java, but the example is meant to illustrate the fact that maybe a "goto" isn't such a horrible, evil thing when applied correctly.
[0] .. and reading it daily really makes you appreciate your co-workers quite a bit more!
[1] Don't forget, we're talking Java here, there is no unconditional branching in Java
[2] Many will say that about me and often they will be right!
[3] Amusingly enough, that's something I don't like at all and avoid doing.. but try not to preach about, it's often style over substance.