|
| Lew <lew@nospam.lewscanon.com> wrote:
Chris Smith wrote:[color=darkred]
> Not in any meaningful sense of the word. It is impossible to write non-
> trivial code of reasonable quality in Java without using the throws
> clause.
Because it is so useful. You are supporting my point. But from a syntactic and
semantic point of view, it is optional. When you write the method, you decide
whether to include a throws clause. If you do, it is because the clause was
useful. If you cannot write a non-trivial program without using the throws
clause, and I agree with that by and large, it is because the throws clause
solves non-trivial problems.
If you are saying you cannot write a non-trivial program without handling
checked exceptions that someone else wrote, again I agree with you by and
large, but that is because the throws clause is doing exactly what it is
supposed to do. Those API writers were told that the throws clause would force
you to deal with certain exceptions. Now you are forced to deal with those
exceptions. It did what it was supposed to do.
People, the throws clause exists to force you to deal with the checked
exceptions. Your complaint is that you are forced to deal with the exceptions
declared in the throws clause. That just means the throws clause did its job.
It is there to force you to deal with those exceptions. How else would an API
designer force you to deal with those exceptions?
If you do not like it, do not blame the language for giving those API
designers too much power. After all, it is a power you yourself may choose to
wield on the users of your own code (yourself included).
- Lew
|
|