Exception Shielding
July 7, 2009 4:34 amMy previous post spent over 600 words knocking down the Exception Handling Block, but version 3 and higher does have one nice feature: WCF Exception Shielding. This allows exceptions received by a WCF service to be mapped to Fault Contracts.
Exception shielding is important in order to hide internal implementation details from service consumers. This can make your service easier to use and, more importantly, prevent exposing sensitive internal information in your exceptions.
Enterprise Library Exception Shielding seems to be a good use of configuration to decouple a service interface from the underlying implementation.
Categories: .Net
No Comments »
Exception Handling (Block) & Enterprise Library
May 17, 2009 4:38 amLately, I've been thinking about exceptions vs. error codes. As usual, Joel On Software has a couple of well thought out posts on the topic. The first post makes the point that exceptions "create too many possible exit points for a function". The second post, Making Wrong Code Look Wrong makes some very good points on exception handling as well as other topics. In the same way that compile time errors are better than runtime errors, it is better to find errors in code simply by reading the code than by being forced to run or debug the code. That seems like a pretty straight forward statement to me but I'm wondering if people actually agree with it -- what with the popularity of various frameworks where everything is hung together with configuration files.
Those two ideas -- exceptions as flow control and making code look wrong -- led me to think about why I really, really dislike Microsoft's Enterprise Library Exception Handling Block: it combines the worst parts of both.
Consider the following:
-
try
-
{
-
DoSomething();
-
}
-
catch (Exception e)
-
{
-
bool rethrow =
-
ExceptionManager.HandleException(e,
-
"MySpecialPolicy");
-
-
if (rethrow)
-
{
-
throw;
-
}
-
}
My objection: you have no idea what the exception handler does!
Since you can't tell what will happen at this one point, you can't mentally trace the program flow to see if it's logically sound. This makes development, tracking down bugs, and overall maintenance difficult.
"Wait, wait, wait", you say. "You can create meaningful policy names to avoid this kind of confusion". Yes, you can change the policy name to something more meaningful like "BusinessLayerMustRethrowPolicy" so you can understand the intent of the code -- which is a good thing. However, you still have no idea of the actual behavior at run time since the configuration could be set to not rethrow (for some reason). Plus, if you are making your exception handling configuration based, then you are implicitly saying that you allow the configuration to be changed to another setting (e.g. not rethrow an exception). Isn't that the point of putting things in configuration? To allow behavior to be changed without changing the code.
Since throwing an exception changes the flow of the program, if you modify the Exception Handling Block configuration (behavior) then you are actually creating a new execution path. Does that mean the program should run "properly" for all possible settings of the configuration? (Not likely!) Do you then have to test all of those possible code paths?
Maybe you could implement a policy of no configuration changes without a full test cycle but then how is that much different than performing a code change? You do skip the issue of introducing a new coding bug
and you avoid a build but you still need to create some sort of deployment package and go through a release cycle (which is the most expensive part in this lifecycle). Plus there is always the chance of the configuration becoming incorrect "by accident" and the new execution path may introduce some undesirable behavior. e.g. maybe database changes are committed because, even though an exception occurred, the policy said to not throw an exception and the calling code assumed that all errors would be reported as exceptions.
Other objections to the Exception Handling Block:
- As a framework, the "if rethrow" construct doesn't really offer a lot of abstraction; you still need to pepper your code with "if rethrow" code in every catch block.
- If you try to use the logging block to log an exception, every log entry for that handler shares all of the same basic log entry information (e.g. event ID). This can be restricting if you need that kind of control.
In general, I avoid the Exception Handling Application Block because it obfuscates the functioning of the program which makes the program harder to understand and maintain. To me this outweighs any functionality provided by the block.
Categories: .Net
1 Comment »
Farewell, Scrubs
May 12, 2009 4:38 amScrubs wrapped up what looks to be its final season with a really good 1 hour finale. The last 2 seasons have been hit and miss and rarely hit the incredible highs of previous years but it was nice to see Scrubs rescued by ABC so it could end its run on its own terms. The finale was a fitting end to one of the funniest and most under rated shows ever. Scrubs, more than any other show, could play broad comedy one minute and the next minute be deadly serious. You'd think the effect would be too jarring but somehow they made it work.
In honor of the finale here is my list of best Scrubs episodes (in no particular order -- almost):
1. My Old Lady
2. My Monster
3. My Own American Girl -- Elliot gets a backbone!
4. My Occurrence
5. My Screw Up
And, in my opinion, the best Scrubs episode ever:
6. My Way Home
Categories: TV
No Comments »
Foods I Miss #2
February 1, 2009 6:02 amSarasoda was "the sparkling citrus cooler for adults" (as the ad says) that had a minimal alcohol content. It was mainly available in the 80's and I"m not sure if it was specific to Canada or if it was widely available. It was expensive for the time -- I seem to remember it selling for the very high price of 1 dollar. Obviously, at that price this was a beverage only for special occasions.
Although I was not quite an adult, I still bought quite a few over the years and they were worth the extra money. Yum!
If anyone has any other information or memories please share.
Categories: Food
2 Comments »
Nice Try, QuickTax
January 29, 2009 5:49 amI got my new copy of QuickTax in the mail the other day.
No, I didn't pay for it. I didn't even ask for it!
In a previous post, I wrote about why I wouldn't be using QuickTax any longer. It seems that Intuit has decided to mail out physical CDs of QuickTax in the hope of getting folks to install it and then purchase the software. I think it reeks of a desperate attempt to recapture their lost sales and I'm hoping that people don't fall for this and that this ends up costing Intuit more money than they recoup.
Yes, I'm still bitter over last years money grab.
Categories: Finance
No Comments »
Foods I Miss #1
January 10, 2009 5:31 amNumber one in a series (?) of "foods that I wish I could still eat". Maybe I'm watching too much Food TV or something?
For the first installation, we honor the late great cereal: Crispy Wheats 'N Raisins. For those of you who don't remember, Crispy Wheats 'N Raisins launched in the late 70's and, in 1996, was re-branded Crispy Wheaties 'N Raisins. Unfortunately, even that name change couldn't change the cereal's fortune and it was eventually discontinued.
Man, that was a good cereal.
I couldn't track down the classic "Wizard of Oz" commercials so here is another one:
Anyone have any other selections?
Categories: Food
2 Comments »
Not So Fast, QuickTax!
December 16, 2008 6:29 amA few days ago I got an email from QuickTax announcing: "QuickTax, more value now with 8 returns". Of course, they forgot to mention that they totally ripped everyone off last year when they reduced the number of returns from 5 down to 2. Now they increase the number of returns up and we are supposed to jump up and down? I don't think so. Last year, I purchased QuickTax without realizing that the number of returns was too small for my needs. So, I actually had to go out and either buy more licenses of QuickTax (not likely!) or buy another product. I chose to purchase UFile mainly because of the price. Sure, it was a different way to do the tax return but, you know what? Previous years QuickTax forms were imported fine, the return got done and it cost less than QuickTax. I'm also thinking about not spending anything for tax software and using studiotax instead.
Whichever way I decide, one thing is certain, Intuit will not be receiving any more of my money.
Categories: Finance
1 Comment »
CSI After Eight
October 14, 2008 12:32 amNo, not the mint. CSI started it's 9th season last week with a great conclusion to last years Warrick cliffhanger. It is nice to see William Petersen getting some credit after 8 years (for example, here and here). Despite the character's introverted nature, his portrayal of Grissom has been the heart of the show since the debut episode.
The first episode of season 9 was one of the best single episodes in recent memory (the miniature killer arc was great from season 7) and Petersen's performance was masterful in its controlled emotion. In the opening scene, Grissom's clenched jaw communicates so much.
Categories: TV
No Comments »
A Feeble Breeze
October 3, 2008 3:58 amHeather Mallick's September 5th column (now removed) caused quite the backlash against her and the CBC. Initially the CBC stood behind the hatchet job article. On September 25th, the CBC Ombudsman, Vince Carlin, issued his review of the matter. He agrees that the article offers little facts to back up the "opinions" (my air quotes) presented in the article. He also notes that CBCNews.ca does not present a diverse range of opinions.
Four days later, publisher John Cruickshank offers up...well not quite an apology. I'm not actually sure what you would call it. I guess the best would be an admission of judgment error. On the plus side, Mr. Cruickshank indicates that the CBC will attempt to expand it's diversity of opinions.
I think that is a good step. By all means let the CBC present opinions but let's focus on the ideas, reasoning and thoughts behind those opinions and not on how people look, what gender they are or what their family is like. And if opinions are presented, then please present a wide range of opinions from all sides.
It seems like the least we could ask from Canada's public broadcaster.
Categories: Politics
No Comments »



