Is it a good practice to suppress warnings?
- by Chris Cooper
Sometimes while writing Java in Eclipse, I write code that generates warnings. A common one is this, which I get when extending the Exception class:
public class NumberDivideException extends Exception {
public NumberDivideException() {
super("Illegal complex number operation!");
}
public NumberDivideException(String s) {
super(s);
}
} // end NumberDivideException
The warning:
The serializable class NumberDivideException does not declare a static final serialVersionUID field of type long.
I know this warning is caused by my failure to... well, it says right above. I could solve it by including the serialVersionUID, but this is a one hour tiny assignment for school; I don't plan on serializing it anytime soon...
The other option, of course, is to let Eclipse add @SuppressWarnings("serial").
But every time my mouse hovers over the Suppress option, I feel a little guilty.
For programming in general, is it a good habit to suppress warnings?
(Also, as a side question, is adding a "generated" serialVersionUID like serialVersionUID = -1049317663306637382L; the proper way to add a serialVersionUID, or do I have to determine the number some other way?)