The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Proper exception handling

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Darrell Norton

Posts: 876
Nickname: dnorton
Registered: Mar, 2004

Darrell Norton is a consultant for CapTech Ventures.
Proper exception handling Posted: Aug 25, 2004 1:00 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Darrell Norton.
Original Post: Proper exception handling
Feed Title: Darrell Norton's Blog
Feed URL: /error.htm?aspxerrorpath=/blogs/darrell.norton/Rss.aspx
Feed Description: Agile Software Development: Scrum, XP, et al with .NET
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Darrell Norton
Latest Posts From Darrell Norton's Blog

Advertisement

I’m going to throw my two cents into the exception discussion that Brendan brought up. I believe Jeffrey Richter's approach is the best, which I learned in person at Devscovery (the “low level” sessions like this were the best ones in the conference). The East Bay IT Group (ebig) has a great overview of Jeff’s exception talk, shown here in part:

“Jeffrey began his talk by defining an exception as an event that occurs when an implicit assumption is violated, and not as many people erroneously believe, simply a rarely occurring event. When an implicit assumption is violated, an exception event should be generated rather than having the function return an error code. Jeffrey gave a great example of how the legacy tradition of returning a -1 for a file read function at the end of a file is actually improper and how it can cause coding difficulties and application errors.

Richter presented an impressive list of the benefits of exception handling. By using more robust, maintainable object oriented code, the result is cleaner, uncluttered centralized program logic. One of the unexpected benefits of exception handling is better performance because many errors can be processed centrally instead of after each function call. Although some early implementations of exception handling using C++ had poor performance, the efficiency of Microsoft’s .NET garbage collector has all but eliminated these problems.

Jeffrey ended his talk with guidelines and best practices for exception handling including liberal use of finally blocks, catching specific exceptions (only lazy developers catch all), graceful recovery design pattern, and backing out but not swallowing of exceptions.

In his presentation on exception handling, Jeffrey did more than describe the rules and show code examples for exception handling on .NET (which, of course, he did exceptionally well). He described a common sense way of looking at exceptions that everyone in the audience could understand. Jeffrey said that an exception occurs when an implicit assumption is violated, and not, as many people erroneously believe, when a rare event has occurred. Richter ended his talk on a positive note, demonstrating that proper handling of exceptions produces cleaner, less cluttered code that is easy to understand and is highly performant.” [ebig newsletter]


This Blog Hosted On: http://www.DotNetJunkies.com/

Read: Proper exception handling

Topic: Build Printable ASP.NET Pages Previous Topic   Next Topic Topic: Just What is VSHOST?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use