Goto and the art of evil

Posted on

There are some crimes in development that are just so evil you don’t even mention them by name. Using the GOTO keyword is the first of them.

I have just been handed a piece of code to review, the very first line was the label and I instantly stopped. I haven’t seen labels in code for 10 years. I quickly scan down the code and there is it.. GOTO. I didn’t even bother running the code I just closed the project. Just looking at it makes me feel dirty.

Yes the GOTO keyword is in C#, but that doesn’t mean you should be using it. In the same way the barrel of a gun fits nicely in the mouth doesn’t mean that is where you should put it.

Leave a Reply

Your email address will not be published.