IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Checked Exceptions: A Failed Experiment
Checked exceptions are an experiment in language design that unfortunately didn't pan out. They sound good on paper, but in practice cause far more pain that they are worth.

Most of Goslings argument for checked exceptions are really arguments for exceptions, not necessarily checked ones.

[an aside] ... Scott, your last two sentences seem to imply that RuntimeExceptions should not be handled (e.g. caught). It was my impression that it is the Error hierarchy that should not be caught. The Runtime hierarchy are unchecked because they contain exceptions that could happen anywhere (e.g. NullPointerException), so making them checked would mean nearly every method would have to declare them.
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Re: Checked Exceptions: A Failed Experiment
My point was that people abuse the nature of RuntimeExceptions in order to avoid having to declare anything, so you end up with code that doesn't use checked exceptions when it "ought" to.

Whether this is easier or not isn't the question; such a practice makes maintenance difficult because people generally expect code to work like Java ought to. They aren't expecting unchecked application exceptions.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Re: Checked Exceptions: A Failed Experiment
My point was that people abuse the nature of RuntimeExceptions in order to avoid having to declare anything, so you end up with code that doesn't use checked exceptions when it "ought" to.

Hmmm ... kinda assumes that there is a time when one should used checked exceptions. In your opinion when are checked exceptions to be used, and when should they not be used?

BTW, Bruce Eckel suggests using RuntimeExceptions everywhere and wrapping checked exceptions from third party code in a Runtime exception wrapper when they cross the border into your code. My approach is to simply use "throws Exception" on any method that might throw any kind of exception. I rarely care what the specific exception is.
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
New Note the quotes: "ought" to.
Bending the paradigm simply makes things difficult for other programmers maintaining your code, unless it is bent the same way all the time. While I personally dislike checked exceptions - at least when required all of the time; as I mentioned it's handy sometimes to remind me what might get thrown - I've also worked with people that needed such a crutch all of the time. As a result, in mixed shops of varying ability levels, I think that people ought to use checked exceptions. They're expected, and one of the keys to maintenance-friendly programming is "do what's expected".

I've mentioned this [link|/forums/render/content/show?contentid=100013|before], but it bears repeating: Java is a giant compromise that allows mediocre and good programmers to co-exist without killing each other. When I'm programming for/by myself, I don't use Java, for reasons including things like checked exceptions.
Regards,

-scott anderson

"Welcome to Rivendell, Mr. Anderson..."
New Thanks
Thanks for the clarification. That's certainly a reasonable position.

In a mixed-skill shop (actually, any multi-programmer shop), I would encourage the group to establish coding standards or best practices that are reasonable and appropriate for the group. A common approach to exception handling (that addresses the checked exception issues) should be one of those practices.
--
-- Jim Weirich jweirich@one.net [link|http://onestepback.org|http://onestepback.org]
---------------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)
     Checked Exceptions, Good or Bad - (bluke) - (25)
         Agreed, for the most part. - (admin) - (5)
             Checked Exceptions: A Failed Experiment - (JimWeirich) - (4)
                 Re: Checked Exceptions: A Failed Experiment - (admin) - (3)
                     Re: Checked Exceptions: A Failed Experiment - (JimWeirich) - (2)
                         Note the quotes: "ought" to. - (admin) - (1)
                             Thanks - (JimWeirich)
         Bad of course - (tuberculosis)
         Hey look - I got a new sig out of that article - (tuberculosis) - (1)
             Buahahah. -NT - (admin)
         Designers should ALWAYS look for pushback - (ben_tilly) - (15)
             OT: I didn't picture you reading Cato stuff. :-) - (Another Scott) - (5)
                 I don't generally - (ben_tilly) - (4)
                     I can't offer an opinion. - (Another Scott) - (3)
                         Cato's been mucking around since the '60s at least - (Ashton) - (2)
                             Re: Cato's been mucking around since the '60s at least - (neelk) - (1)
                                 Re: Cato's been mucking around since the '60s at least - (Ashton)
             Re: Designers should ALWAYS look for pushback - (neelk) - (8)
                 How do you do "meta" flow of control? - (ben_tilly) - (7)
                     Another possible solution to exceptions... - (ChrisR) - (6)
                         Not appropriate for the situation being discussed - (ben_tilly) - (5)
                             Actually I'm mostly interested in what... - (ChrisR) - (4)
                                 What my thinking on this is... - (ben_tilly)
                                 Re: Actually I'm mostly interested in what... - (neelk) - (2)
                                     Why not include the exception processing in the lambda? - (ChrisR) - (1)
                                         Re: Why not include the exception processing in the lambda? - (neelk)

I don't know who thought this up, but it certainly wasn't a bird.
235 ms