I understand the theoretical benefit of checked exceptions, but reality trumps theory. They simply don't scale and lead to swallowed/ hidden exceptions. I've seen quite a few open source APIs that have "throws Exception" in them. And generally the open source APIs are done by some of the best coders!
Another issue I didn't mention is checked exceptions pollute the interface. Lets say you have a public API (interface) and add a new exception type. This makes every consumer of your API's code break. This violates the concept of having an API "contract". So with checked exceptions either you are forced to 1) violate the contract or 2) not throw the exception you want to throw and wrap it in an unsuitable exception or 3) use a runtime exception. 3 is best:) people are so concerned with not knowing what exceptions are thrown, but if you test your projects you will discover when there are exceptions that are thrown and you want to handle. It's a rare occurrence. usually there is nothing you can do about it, so knowing that it will be thrown doesn't really help you out. I mean seriously, what do you do when you get a SQL Exception? it's almost always a bug. and a bug that might not be discovered if you used a checked exception and swallowed it. On Aug 18, 4:13 am, Peter Becker <[email protected]> wrote: > I still believe that the main reason people hate checked exceptions is > that they have been used badly. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "The Java Posse" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/javaposse?hl=en -~----------~----~----~----~------~----~------~--~---
