Friday, January 27, 2012

Is it bad that I have 37 'goto' 's in my code, or should I change it?

The program works (it's a unit converter gui program), but it has a lot of goto's. The teacher said that he doesn't like them (he doesn't like spaghetti plates), but I felt that my approach was ok.Is it bad that I have 37 'goto' 's in my code, or should I change it?
Yes, it's bad. Why are you using goto's? There is hardly ever a good reason to use them. What are you using them for? Can you not do the same thing with if statements and loops? Usually you can.



It's not that you should never use goto. I probably use 1 or 2 of them a year. 37 in 1 small app, yes, that's bad.
using goto statements is bad design. You should have 0 of them.



It would be one thing if you were using MIPS, or assembly or something, but I'm pretty sure you aern't.Is it bad that I have 37 'goto' 's in my code, or should I change it?
BAD! Gotos are considered horrible coding style and should not be used at all; there is always another way.Is it bad that I have 37 'goto' 's in my code, or should I change it?
It's not ok. Change your code so you don't use goto statements.

No comments:

Post a Comment