RE: Exceptions (was: RE: [Avalon4:PROPOSAL] Context Consensus)
"Noel J. Bergman" <[email protected]>
| Newsgroups | gmane.comp.jakarta.avalon.apps.devel,gmane.comp.jakarta.avalon.devel |
|---|---|
| Message-ID | <[email protected]> |
Nicola, > Tell me that I should expect runtime or nullpointer exceptions, and my > alarm bells will start ringing so hard it could heafen half the world ;-) When I find code explicitly throwing runtime exceptions, it is healthier for the author to be nowhere near me. But that is usually a reaction to having just debugged a problem where someone threw a runtime exception, didn't document that it might, and I didn't catch it deep enough. Runtime exceptions are a necessary evil (think of a typical null pointer or index out of bounds), but evil. They should be used with great discretion. Runtime exceptions are undocumented far too often by authors, and even if you think to have internal "firewalls" to catch them in reasonable places, you can overlook something. I wish that Sun had named the class "UndeclaredException", which provides the correct semantic spin. Doug Lea had an interesting proposal for addressing them: http://gee.cs.oswego.edu/dl/html/javaCodingStd.html. One of my other peeves is directed at code that throws exceptions without putting sufficient information in the exception to diagnose the correction. --- Noel