4 ms·
> certain scale Make it explicit. If the array is too large, throw an IllegalArgumentException. Document the limit. Then I agree with you. Otherwise, if an al
by alanfranz 2y ago
> certain scale
Make it explicit. If the array is too large, throw an IllegalArgumentException. Document the limit. Then I agree with you.
Otherwise, if an allowed input crashes the program at runtime with a random exception, I respectfully disagree.
- brabel 2y agoThen you should absolutely stay away from C :)
- feoren 2y agoIllegalArgumentException is OK in your book, but OverflowException is not? It's very rare that I actually care which exception type is thrown, but it's a little more polite to throw more clear and reliable exception types. But saying "this could be a little more polite and therefore YOUR CODE HAS A BUG" would make me never want to work with you again.
- alanfranz 2y agoExplict OverflowException could be ok but it may not tell me the root cause. A random index error is not ok at any time.