Re: Real life cost of using exceptions for control flow?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Justin Rogers (Justin_at_games4dotnet.com)
Date: 06/18/04


Date: Fri, 18 Jun 2004 11:53:22 -0700


> You should write your program so that there are no exceptions "as long as
> your program operates in normal conditions" (and bad input is one of the

I love this statement, so I'll make a quick comment. The discussion in my
opinion is getting very good since both sides of the exception camp are present.
However, the above statement draws our differences. You see, as a WinSock
programmer, I know that a lost network connection is not an exceptional
circumstance. It just isn't. The reliability and quality of service present on
a
single land line, DSL connection, and on all network connections between two
hosts is fragile at times. A dropped connection is a *normal* program occurence
and in many cases is something you have to respond to IMMEDIATELY.

Communications code is very privy to this type of issue. At times, a
concurrency
protocol will require conversions and other things happen within small windows
of 10-15 ms. Dropping the network connection and getting an exception eats away
my window. If I am a reliable programmer, the second connection was already up
and redundant probably through some extra set of host adapters on a different
physical connection, which I switch over to and continue my concurrency protocol
without interruption.

Whether or not something is exceptional is up to the programmer. Especially for
spurious exceptions like out-of-space on the disk. A reliable programmer sets
the
length of the file up front and ensures he can write as much data as he
requires.
Now a HD crashing IS an exceptional case, but most of those you pointed out,
are not, in many cases, exceptional at all.

Maybe that is why the camps are so split? The perception of exceptional is a
relative term?

-- 
Justin Rogers
DigiTec Web Consultants, LLC.
Blog: http://weblogs.asp.net/justin_rogers


Relevant Pages

  • Re: Should I use "if" or "try" (as a matter of speed)?
    ... Joel Spolsky might be a great C++ programmer, ... arguments about exceptions do not hold in Python. ...
    (comp.lang.python)
  • Re: Runtime error in Java 6
    ... ignored) abound in code that you can't do anything about, like the JDK classes. ... Try running some Java program under a debugger that breaks on all exceptions and you'll see what I mean. ... The API part throws Exceptions, in part because an API writer ... Unchecked Exceptions are for programmer error. ...
    (comp.lang.java.programmer)
  • Re: I cant believe how complex this Format SDK is...
    ... I've been a programmer since '80. ... provides me with an unbiased perspective on the docs and APIs. ... Overall I think the documentation is reasonably good, ... run my app in the debugger, such as first-chance exceptions when using ...
    (microsoft.public.windowsmedia.sdk)
  • Re: java.lang Exception hierarchy - why?
    ... >>RuntimeException has been placed as a subclass ... A program declaring such exceptions would be ... reference to unchecked and checked exceptions. ... > though this may be obvious to the programmer. ...
    (comp.lang.java.programmer)
  • Re: Another shitty example of exceptions
    ... Its entirely up to the programmer. ... Are you talking just about Delphi exceptions or exceptions in ... > into the bit bucket instead of down a valid connection. ... > affecting higher levels of code. ...
    (alt.comp.lang.borland-delphi)