If a method checks its input and detects an invalid input, what should it do: raise an exception (or use a different error mechanism) or do nothing / ignore incorrect input?
In Java, the HashTable class throws a NullPointerException if null references are specified as a parameter. This is sometimes annoying, but I think it can have advantages because errors are caught early. Some other methods ignore illegal input without doing anything. This is less annoying and usually nothing bad happens, but there may be cases, then this behavior causes headaches - or not?
I'm not sure which way is better. Therefore, I ask you: what do you think about this issue?
source
share