3 ms·
I think checked exceptions are great. When using a library you instantly know what all bad could happen while calling a function and retry/handle on specific ex
by apexkid 8y ago
I think checked exceptions are great. When using a library you instantly know what all bad could happen while calling a function and retry/handle on specific exceptions. For example, when reading a file if you get something like a FileNotFoundException, you can treat it as a fatal case or can simply move to process the next file. This provides a lot more clarity to code and resonates with the static type safety paradigm of java.
- sorokod 8y agoI think that a common criticisms is that in many cases, regardless of whether the exception is checked or unchecked, there is little the process will do but give up. Because this is common and sensible, the code ends up with either many exception handlers that convert checked to unchecked or add the exception to the calling method signature which propagates the problem up that call stack
- deleted 8y ago[deleted]
- smsm42 8y agoChecked exceptions are great in some cases. They are huge annoyance in others. The complaint is that the language does not provide tools to separate these cases - you can't just say "this method doesn't handle exceptions, pass it up" or "ok, now I want all exceptions to be handled, so tell me if I forgot something". It does not give the programmer control. Java has excellent facilities to make it happen - annotation, static analysis tools, extensive array of code checkers - but all this has to bow to the built-in mechanism which is crude and inflexible.