Stefano Mazzocchi wrote:
> Leo Sutic wrote:
>
>
>>A lookup failing is an exceptional
>>case, and should be treated as such.
>
>
> I think this is the key issuse here.
>
> Example, I might change the behavior of a component, if another
> component it requires is missing (this happens in Cocoon a lot)
>
> This is *not* an exceptional case, but a straightforward programming
> flow.
>
> Making the exceptions thrown a RuntimeException allows people that
> consider lookups an exceptional case to use try/catch and those who use
> it as a programming flow, to use normal method calls (or ignore the
> exists() alltogether)
*ALL* Runtime exceptions go unnoticed to programmers.
Give me three programmers that check that a class throws
RuntimeExceptions; I know none.
> As for the argument that try/catch enforce good programming practices, I
> can point you to a bunch of
>
> try {
> ...
> } catch (Exception e) {}
>
> examples even in high-quality code that show you this is *NOT* the case:
> you can't force programmers to be smart, but you can give them tools
> that match their differences.
But you can make them take a decision.
With try-catch they at least need to know that there is something to catch.
With Runtime ones, nobody would know, even the programmers that use
try-catch the correct way.
Let me give you a concrete example: Cocoon exceptions.
Cocoon used many RuntimeException, also in the XSLT components, and many
of them were really difficult to track down.
With RuntimeExceptions, you are taking the compulsory responsibility of
handling them away from the method caller.
I am *strongly* against RuntimeExceptions, having been burnt many and
many times because of them.
What is the most common exception that one gets that basically has no
meaning, is hard to track down and is never handled:
java.lang.NullPointerException, which is a java.lang.RuntimeException.
You want Avalon to throw "NullPointerExceptions" ?
--
Nicola Ken Barozzi [EMAIL PROTECTED]
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>