Re: Inheritance.
"Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> wrote in message
news:44531028$0$650$bed64819@news.gradwell.net...
Mike Schilling wrote:
But sometimes necessary. Consider, as an example, an Iterator that
returns successive lines from a file. If calling next() results in an
IOException reading the file, I don't see any alternative to wrapping it
in some sort of RuntimeException and throwing the result.
Alternatively, you could consider the contract inherited from the
superclass
and conclude that it is not possible to satisfy it with an iteration
subject to
that mode of failure.
Or you rationalize that the file going unreadable after it's been opened
cleanly, while you're reading lines from it, is the sort of unanticipated,
"I don't know what the hell to do next" problem that unchecked exceptions
are for. (It occurs to me that the example is poor for a more important
reason. Part of the implicit contract for Iterator is that it's safe to
stop iterating at any time. Thus there's no guarantee the file ever gets
closed. Oh well.)