I recently attended the “Debugging .NET Applications” 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.
Some of you might totally disagree with me and I can understand. He is a great author.
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.
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.
Here are some do's and dont's for .NET excptions.
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.
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.
-Ashish