Thinking In .NET

Source code for Thinking in C#

Free C# Compilers

Personal Homepage

Thinking In .NET

A place to learn about C# and the .NET platform, by Larry O'Brien. But mostly the obligatory braindump cross-linking that characterizes the blogsphere.

To receive an occasional announcement message regarding my seminars or publications, please subscribe to my mailing list.

Email:

Sunday, September 29, 2002

Java vs. C#: Checked vs. Unchecked Exceptions

Billy Barrett writes:

I have come to the conclusion that writing a highly robust application with C# is nearly impossible because of [reasons such as...] you are catching the exceptions that are being thrown and then the person who wrote the component you are using adds a new exception. As you realize, they will more often than not forget to tell you and now you won't be handling it.

I can't think of a crisis scenario. At iteration 1, the system is working and handling exceptions A, B, and C. At iteration 2, new exceptions D and E are introduced. D is a subtype of C, an E is a totally new exception, unlike anything that's gone before. Presumably, our code that handles C should handle D just fine. In Java, we can't get a successful compile until we address the issue of E, while in C#, the compilation works fine, but the first time that an "E" is thrown, the system stops. No code breaks that shouldn't, i.e., the only time the system fails is when the system is in a state that generated this new, unlike-anything-we've-seen-before exception, which means that either the system is dealing with a scenario we hadn't dealt with in iteration 1 or our understanding or requirements for the scenario have changed. One way or the other, the code that breaks, should break.

It's important to note that with .NET we do not face the DLL Hell of introducing an iteration 2, E-throwing component into a system that depends on the iteration 1, only-A,B,C-throwing component. The versioning stuff can ensure that if our system is only robust with the iteration 1 A,B,C-throwing component, then our system will continue to use the proper component.

The only scenario where things break down is when I just slipstream the throwing of E, without letting anyone know that I've introduced dramatic new behavior to the system. But do we really want or need a compiler to be the guard against such behavior?


11:46:05 AM    comment []

All the cool kids are going to the Sells Brothers Web Services DevCon 10-11 Oct in Bedford, MA. I've been spending all my time preparing for the BZ Media Web Services Dev Con happening this week in NYC. Both should be good but the Sells Brothers is clearly more technically oriented; I wish I could go.
11:37:58 AM    comment []


The contents of these pages represent the opinions of one person.
All contents © 2002 Larry O'Brien. All Rights Reserved.

 

September 2002
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Aug   Oct


Click here to visit the Radio UserLand website.

Subscribe to "Thinking In .NET" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.