<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:evnet="http://www.mscommunities.com/rssmodule/"><channel><title>Comment Feed for Exceptions (Posts on Channel 8)</title><atom:link rel="self" type="application/rss+xml" href="http://channel8.msdn.com/posts/exceptions/rss/default.aspx" /><image><url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/Channel8/images/feedimage.png</url><title>Comment Feed for Exceptions (Posts on Channel 8)</title><link>http://channel8.msdn.com/Posts/Exceptions/</link></image><description>Exceptions</description><link>http://channel8.msdn.com/Posts/Exceptions/</link><language>en-us</language><pubDate>Wed, 28 May 2008 22:15:48 GMT</pubDate><lastBuildDate>Wed, 28 May 2008 22:15:48 GMT</lastBuildDate><generator>EvNet (EvNet, Version=1.0.3163.4106, Culture=neutral, PublicKeyToken=null)</generator><item><title>Re: Re: Re: Re: Re: Exceptions</title><description>Thanks diegum.&amp;nbsp; :)</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6312</link><pubDate>Wed, 28 May 2008 22:15:48 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6312</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6312/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Thanks diegum.&amp;nbsp; :)</evnet:previewtext><dc:creator>gogole</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6312/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Re: Exceptions</title><description>I believe my folks answered your questions on Exceptions, Donald. I've just got some few more guidance on that coming directly from MS architects related with .NET framework evolution&lt;br /&gt;&lt;br /&gt;The 1st one is and old book on performance and scalability (although it's on .NET 1.1, the statements on&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998547.aspx#scalenetchapt05_topic24" target="ExcLinks"&gt;Exception Management&lt;/a&gt; yet apply to the current versions of that managed environment). Worth reading:&amp;nbsp;&lt;a href="http://msdn.microsoft.com/en-us/library/ms998547.aspx#scalenetchapt05_topic24" target="ExcWindow"&gt;http://msdn.microsoft.com/en-us/library/ms998547.aspx#scalenetchapt05_topic24&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The other useful reference is a&amp;nbsp;&lt;a href="http://www.researchchannel.org/prog/displayevent.aspx?rID=11087&amp;amp;fID=2740" target="ExcWindow"&gt;session delivered by Krzysztof Cwalina&lt;/a&gt; (father of the .NET Base Class Library). While the session is about more than three hours on framework development guidance (worth saving the time to watch it all), the particular part for Exception Management comes at 2:23:11 (two hours, twenty three minutes, eleven seconds :-)&lt;br /&gt;&lt;a href="http://www.researchchannel.org/prog/displayevent.aspx?rID=11087&amp;amp;fID=2740" target="ExcWindow"&gt;http://www.researchchannel.org/prog/displayevent.aspx?rID=11087&amp;amp;fID=2740&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="http://blogs.msdn.com/kcwalina/default.aspx" target="ExcWindow"&gt;Krzysztof&lt;/a&gt;&amp;nbsp;summarized all his thought on exception handling on chapter 7 of his best-seller "&lt;a href="http://www.amazon.com/Framework-Design-Guidelines-Conventions-Development/dp/0321246756/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1211494543&amp;amp;sr=1-1" target="ExcWindow"&gt;Framework Design Guidelines&lt;/a&gt;", whose&amp;nbsp;&lt;a href="http://www.amazon.com/Framework-Design-Guidelines-Conventions-Development/dp/0321545613/ref=pd_bbs_sr_2?ie=UTF8&amp;amp;s=books&amp;amp;qid=1211494543&amp;amp;sr=1-2" target="ExcWindow"&gt;second edition&lt;/a&gt; is coming next year</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6222</link><pubDate>Thu, 22 May 2008 22:18:23 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6222</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6222/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I believe my folks answered your questions on Exceptions, Donald. I've just got some few more guidance on that coming directly from MS architects related with .NET framework evolutionThe 1st one is and old book on performance and scalability (although it's on .NET 1.1, the statements&amp;#8230;</evnet:previewtext><dc:creator>diegum</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6222/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Exceptions</title><description>I have &lt;a target="_blank" href="http://chakkaradeep.wordpress.com/category/tdd/"&gt;blogged&lt;/a&gt; on it :) (the posts have external links too associated with it)&lt;br /&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6067</link><pubDate>Fri, 16 May 2008 07:08:27 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6067</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6067/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I have blogged on it :) (the posts have external links too associated with it)</evnet:previewtext><dc:creator>chakkaradeep</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6067/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Exceptions</title><description>A link to&amp;nbsp;TDD and Agile dev introduction&amp;nbsp;would be helpful ;)</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6058</link><pubDate>Fri, 16 May 2008 02:34:04 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6058</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6058/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>A link to&amp;nbsp;TDD and Agile dev introduction&amp;nbsp;would be helpful ;)</evnet:previewtext><dc:creator>gogole</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6058/Trackback.aspx</trackback:ping></item><item><title>Re: Exceptions</title><description>Actually, If you start using Agile methodologies and Test Driven Development, You eliminate all those NullReferenceExceptions, ArgumentExceptions etc. ;)&lt;br /&gt;</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6054</link><pubDate>Fri, 16 May 2008 01:25:11 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6054</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6054/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Actually, If you start using Agile methodologies and Test Driven Development, You eliminate all those NullReferenceExceptions, ArgumentExceptions etc. ;)</evnet:previewtext><dc:creator>chakkaradeep</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6054/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Exceptions</title><description>Great feedback from you guys. I'll keep your info in mind and i sheepishly accept my testing blunder , i should have run more tests.&lt;br /&gt;Since exceptions should be as specific as possible&amp;nbsp;, when catching them it is a good idea to&amp;nbsp;make use&amp;nbsp;of the exception instance like&amp;nbsp;&amp;nbsp;:&amp;nbsp;catch (NullReferenceException ex){}. With this you'd have access to properties like the exception's stacktrace ,generated message ,source etc which would help in handling the exception.</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6033</link><pubDate>Thu, 15 May 2008 13:21:20 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6033</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6033/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Great feedback from you guys. I'll keep your info in mind and i sheepishly accept my testing blunder , i should have run more tests.Since exceptions should be as specific as possible&amp;nbsp;, when catching them it is a good idea to&amp;nbsp;make use&amp;nbsp;of the exception instance&amp;#8230;</evnet:previewtext><dc:creator>gogole</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6033/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Re: Exceptions</title><description>Interesting that you mention the error code vs exception discussion. I'm really much on the exception side there. Because my idea is to throw an exception only if you are already doomed. In that case the few ms that you loose don't count... I, also don't like error codes because you can simply ignore them. That's what often happens in older applications and then results in weird crashes that nobody understands anymore...</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6030</link><pubDate>Thu, 15 May 2008 13:11:47 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6030</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6030/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Interesting that you mention the error code vs exception discussion. I'm really much on the exception side there. Because my idea is to throw an exception only if you are already doomed. In that case the few ms that you loose don't count... I, also don't like error codes because you can simply&amp;#8230;</evnet:previewtext><dc:creator>littleguru</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6030/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Exceptions</title><description>Christian mentioned the most important point - only catch what you can handle. All too often I see people catching Exception which is just very , very bad.&lt;br /&gt;&lt;br /&gt;I would run something to gather a nice variation of data a few hundred times and perform other forms of statistical analysis on that data to see a true representation of the values collected (e.g. variance, std dev).&lt;br /&gt;&lt;br /&gt;The reason I tend to run things so many times, is because of the scheduler - as the system can be allowing other higher priority processes to utilize the CPU of which their is a varying number at any time.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I think what has been touched on is actually pretty interesting as it brings up the whole Exceptions vs Error code argument, the latter of which tends to be preferred in systems code for the reason Christian mentioned - throwing exceptions IS expensive.&lt;br /&gt;&lt;br /&gt;Another one to watch out for is not not rethrow an exception by saying something like throw ex; rather just put a straigth throw; to preserve the call stack.&lt;br /&gt;&lt;br /&gt;In general I think Christian mentioend the things I would of but I've thrown in a few others as its a pretty interesting area in terms of API design.</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6027</link><pubDate>Thu, 15 May 2008 09:10:55 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6027</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6027/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Christian mentioned the most important point - only catch what you can handle. All too often I see people catching Exception which is just very , very bad.I would run something to gather a nice variation of data a few hundred times and perform other forms of statistical analysis on that data to see&amp;#8230;</evnet:previewtext><dc:creator>gbarnett</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6027/Trackback.aspx</trackback:ping></item><item><title>Re: Exceptions</title><description>Btw., Donald, if you test something like this you need to run it more often... if you run such tests only 3 times there could be a lot of things that influence your testing; like another app could run at higher priority and steal CPU time etc. Also you should always specify on what system you tested; otherwise people don't know how how to put the numbers in relation.</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6020</link><pubDate>Thu, 15 May 2008 07:44:40 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6020</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6020/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>Btw., Donald, if you test something like this you need to run it more often... if you run such tests only 3 times there could be a lot of things that influence your testing; like another app could run at higher priority and steal CPU time etc. Also you should always specify on what system you&amp;#8230;</evnet:previewtext><dc:creator>littleguru</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6020/Trackback.aspx</trackback:ping></item><item><title>Re: Re: Exceptions</title><description>The deal is the following: only putting a try-catch(-finally) into your code doesn't make your application slower; and that's good!&amp;nbsp;If you throw an exception that takes some time because the stack needs to be walked etc.&lt;br /&gt;&lt;br /&gt;Therefore exceptions shouldn't be used for program flow; that means that you don't use exceptions to exit a method or branch or similar... there are other constructs like return, if etc for that. Never use exceptions for that.&lt;br /&gt;&lt;br /&gt;If you follow these guidelines you only throw exceptions if you reach a state (in your app) that's not valid. Like you tried to access something that's null or you open a file that's not existent etc. In other words: when you throw an exception something got terribly wrong and you can't do much about it. In that case it isn't important if your exceptions take like a few milliseconds more because they happen very rare and therefore don't influence your performance much.&lt;br /&gt;&lt;br /&gt;If you take for example the exception that's thrown when you open a file that doesn't exist. You can always avoid that by checking if the file exists in the first place. There are methods to do that. The same applies to null reference exceptions. You can always check if the array (to take Donald's example) has been initialized. If it hasn't perhaps you can only return from the method with a false or something similar...&lt;br /&gt;&lt;br /&gt;Exception might include user input to fix the problem or the application might completely crash; but that's fine!&lt;br /&gt;&lt;br /&gt;There's also another point with exceptions: people think they are evil and that they need to catch all of them. Never do that. &lt;strong&gt;Always only catch what you can handle. All the other stuff don't catch; even if your application crashes.&lt;/strong&gt; Try to understand what crashed the application and see then if you could handle the crash somehow; if you can't don't do anything.</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6019</link><pubDate>Thu, 15 May 2008 07:42:09 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6019</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6019/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>The deal is the following: only putting a try-catch(-finally) into your code doesn't make your application slower; and that's good!&amp;nbsp;If you throw an exception that takes some time because the stack needs to be walked etc.Therefore exceptions shouldn't be used for program flow; that means that&amp;#8230;</evnet:previewtext><dc:creator>littleguru</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6019/Trackback.aspx</trackback:ping></item><item><title>Re: Exceptions</title><description>I wonder how many people actually think of things like this...I'm glad someone does though ;)</description><comments></comments><link>http://channel8.msdn.com/Posts/Exceptions/?CommentID=6017</link><pubDate>Thu, 15 May 2008 04:58:18 GMT</pubDate><guid isPermaLink="false">http://channel8.msdn.com/Posts/Exceptions/?CommentID=6017</guid><evnet:views>0</evnet:views><evnet:viewtrackingurl>http://channel8.msdn.com/6017/WebViewBug.aspx?EVT=0</evnet:viewtrackingurl><evnet:previewtext>I wonder how many people actually think of things like this...I'm glad someone does though ;)</evnet:previewtext><dc:creator>Trix</dc:creator><slash:comments>0</slash:comments><wfw:commentRss></wfw:commentRss><trackback:ping>http://channel8.msdn.com/6017/Trackback.aspx</trackback:ping></item></channel></rss>