Re: Exception Names
- From: Arved Sandstrom <dcest61@xxxxxxxxxxx>
- Date: Wed, 01 Apr 2009 23:55:58 GMT
Tom Anderson wrote:
On Tue, 31 Mar 2009, Lew wrote:
Lew wrote:Besides, there's nothing exceptional about reaching the end of a stream. One would venture to say that one nearly always reaches the end of a stream, *unless* something exceptional happens.
Tom Anderson wrote:I'd say that getting end of stream is a highly exceptional event for a read method. The vast majority of the time, you get a byte back!
Nice little bit of rhetorical spin there.
It's not spin, it's a different perspective.
You define majority relative to the number of read events, where I was referring to the number of streams.
Yes, exactly.
I'm going to stand by the notion that most of the time *one uses a stream* one reads the whole thing. Your statement that most of the reads do not hit the end of the stream is trivially correct, but that still doesn't make reading a stream all the way through an exceptional occurrence.
Okay, fair enough.
I also think that whether an event is exceptional has at best a marginal connection to whether it's a good idea to use an exception for it. I think that's an overly literal and dogmatic approach to take.
tom
Generally I see little rhyme or reason as to why some occurrences in Java are handled with return values and others with exceptions. For example, there's nothing exceptional about not finding a file or trying to write to a read-only file, and yet we've got FileNotFoundException.
IOW, exceptions in Java are typically used for _expected_ behaviour. IMHO rather than discussing what exceptions to add, we ought to be discussing how many exceptions that aren't exceptions we can get rid of. An exception should be for a situation that causes a break away from normal program flow...and handling end of stream doesn't fit that bill.
In case I wasn't clear (:-)), I'm arguing for _more_ methods with return values, not less.
AHS
.
- Follow-Ups:
- Re: Exception Names
- From: Wojtek
- Re: Exception Names
- From: Eric Sosman
- Re: Exception Names
- References:
- Re: Exception Names
- From: Tom Anderson
- Re: Exception Names
- From: Lew
- Re: Exception Names
- From: Tom Anderson
- Re: Exception Names
- Prev by Date: Re: java RESTful web service
- Next by Date: Re: Executable Jar file reading files.
- Previous by thread: Re: Exception Names
- Next by thread: Re: Exception Names
- Index(es):
Relevant Pages
|