$ cat posts/7-tips-for-using-exceptions.md
7 tips for using exceptions
Here are 7 tips for using exceptions in C#
- Don’t use exceptions to control the flow of the application.
- Use validation code to avoid unnecessary exceptions.
- Use the finally block to make sure resources are released.
- Don’t catch exceptions you are not going to handle.
- Keep in mind that rethrowing exceptions is expensive. Almost as expensive as the exception that was thrown in the first place.
- Preserve as much diagnostic information as possible in your exception handlers. It is useful for debugging.
- Use the Performance Monitor to monitor CLR exceptions.
Thanks to Juan Daria Tempesta (DCE instructor) for inspiring this article.
Comments
comments powered by Disqus