"I found this interesting tidbit while making some changes to a .NET application," Tim Kowalski writes.
"Although the original developer claims to 'spend 9/10ths on the rule and not the exception', I would argue it's more like 5/10ths on the excuse, 4/10ths on the rule, and 1/10th avoiding the exception."
catch (Exception ex) { CommonLoggerHelper.DumpException(ex); // Typically I like to minimize the amount of // code I wrap in a try/catch statement. However // honestly, I'm feeling that there are a couple // of potential problems that could arise in my // implementation of the code and I want there to // be *some* thought about what should happen here // if the worst-case-scenario actually happens. // Actually, what I'm about to say mimics many of // the comments I made in the questions.aspx.cs // file. // I have two potential problems ... 1st, if the // web server is reset while my user is on the last // quiz question ready to click the "Finish" button // then all his answers will be lost. 2nd, if the // database connection is lost (or other database // malladies occur) then all the user's answers will // be lost. Yes, yes, yes ... I could construct // some elaborate schemes to ensure this doesn't // happen, but that would require I back-up several // steps and re-do some things about the application. // Since this is simply a tutorial application // I'll just bring these potential issues to your // attention and move on. // This does remind me of a great programmer quote: // "Nine tenths of programming is handling the exceion, // not the rule." I fear too often in my own work // I spend 9/10ths on the rule and not the exception. // To make a long story short, I'm going to take // the easy way out and just redirect the user to // the default.aspx page if there is any trouble. // Yes, makes me feel a little dirty, but due to // time constraints I must move on... Response.Redirect("default.aspx"); }
[Advertisement]
BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!