<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Welcome to my blog - Ashish</title><link>http://blogs.msdn.com/ashgupta/default.aspx</link><description>I just started liking writing. Did I write that correctly ??</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>.NET Exceptions</title><link>http://blogs.msdn.com/ashgupta/archive/2004/05/15/132452.aspx</link><pubDate>Sat, 15 May 2004 09:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:132452</guid><dc:creator>ashgupta</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/ashgupta/comments/132452.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ashgupta/commentrss.aspx?PostID=132452</wfw:commentRss><description>&lt;P&gt;&lt;FONT face=Verdana size=1&gt;&lt;FONT color=#a52a2a size=2&gt;I recently attended the &amp;#8220;Debugging .NET Applications&amp;#8221; course by Jhon Robbins. In contrast to my expectations, the course was not at all like his books. I was a great fan of his books but really got disappointed with the course. He is a really nice person, he will crack nice jokes, make you laugh, but in the end, the course was not delivering what you expect. His demos were not working, the topics were simply overview and he was not talking the class with him.&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#a52a2a size=2&gt;Some of you might totally disagree with me and I can understand. He is a great author.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#a52a2a size=2&gt;Inspite of all the disappointment, I did find some topics useful and one of them was .NET Exceptions. There were some good points which are listed below.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;The idea of exception handling is to give a single place for all the clean up in case of unexpected conditions. .NET exceptions are totally different from C/C++ exception where there was no base class for exception but in .NET. all the exceptions were derived from System.Exception class.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Here are some do's and dont's for .NET excptions.&lt;/FONT&gt;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Never ever throw or catch System.Exception. - The idea is, you should catch what you are throwing, or you should catch if you are calling some function which is throwing an exception because of your wrong input. You should never catch any exception which is coming because of some other reason, like low memory condition etc.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Never throw these exceptions - System.Exception (already covered), System.ApplicationException, System.SystemException, System.NullReferenceException, System.IndexOutOfRangeException.&amp;nbsp; All these exceptions can also be thrown from CLR so there would be now way if you throw any of the above exception and catch, weather the exception was yours or not. Always throw a more specific exception rather than a generic one.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Never throw the exception you caugth by calling &lt;STRONG&gt;throw exp (where exp is the exception you caught).&lt;/STRONG&gt;&amp;nbsp; This will loose the stack trace. Rather, either call &lt;STRONG&gt;throw&lt;/STRONG&gt;, which will rethrow the caught exception with proper stack trace, or create a new exception by setting the innerexception to the exception you just caught. This way, the caller will know the exact stack where the original exception was caused.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Always drive your exception from System.Exception, not from System.ApplicationException. (This is supposed to be from latest Design Guidelines)&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;Drive a new exception only if necessary. If its a generic exception type, throw the existing defined exception. for ex - System.ArgumentNullException.&lt;/FONT&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;When driving your own exception, make sure you provide at least these 3 constructors. 1. parameterless (default) constructor. 2. A single string parameter to set the message. 3. A string and an instance of an exception derived type, so that you can pass the inner exception in the constructor.&lt;/FONT&gt;&lt;/LI&gt;&lt;/OL&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#000080 size=2&gt;In addition to this, exception should be thrown only when there was a voilation of contract between the caller and callee. Is should not be used as a way of communicating results. Remember, exceptions means unexpected conditions where the execution cann't be continued.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#006400 size=2&gt;I found these points useful and thought some of you might find them useful as well. Let me know if you have some more generic guidelines which can be used while writing code.&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT face=Verdana color=#006400 size=2&gt;-Ashish&lt;/FONT&gt;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=132452" width="1" height="1"&gt;</description></item><item><title>A very nice article on Design Pattens</title><link>http://blogs.msdn.com/ashgupta/archive/2004/05/14/132327.aspx</link><pubDate>Sat, 15 May 2004 02:19:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:132327</guid><dc:creator>ashgupta</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/ashgupta/comments/132327.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ashgupta/commentrss.aspx?PostID=132327</wfw:commentRss><description>&lt;P&gt;I wanted to write my own design pattern article but this one is really good. Those of you who are interested in design patterns will really find it useful. &lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;A title=http://www.codeproject.com/csharp/SinagaStorageExplorer.asp href="http://www.codeproject.com/csharp/SinagaStorageExplorer.asp"&gt;http://www.codeproject.com/csharp/SinagaStorageExplorer.asp&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;Please fell free to reply with better article if you know.&lt;/P&gt;
&lt;P&gt;I will write my own very soon.&lt;/P&gt;
&lt;P&gt;-Ashish&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=132327" width="1" height="1"&gt;</description></item><item><title>I am up and running</title><link>http://blogs.msdn.com/ashgupta/archive/2004/05/14/132085.aspx</link><pubDate>Fri, 14 May 2004 20:42:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:132085</guid><dc:creator>ashgupta</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/ashgupta/comments/132085.aspx</comments><wfw:commentRss>http://blogs.msdn.com/ashgupta/commentrss.aspx?PostID=132085</wfw:commentRss><description>&lt;P&gt;Finally.... I got my own blog setup. This is so cool. I was thinking about writing on so many topics but didn't know how to start.&lt;/P&gt;
&lt;P&gt;Now when I am up and running, watch out for real blogs to come.&lt;/P&gt;
&lt;P&gt;take care,&lt;/P&gt;
&lt;P&gt;Ashish&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=132085" width="1" height="1"&gt;</description></item></channel></rss>