Relearning Lessons

It's never fun relearning something you already knew…

  • Last year I worked a lot against a database that was missing a lot of referential integrity and even a few uniqueness checks.  You know how the old timers say that's a really bad thing, but you've never actually seen it happen because you don't ever leave off the integrity?  Orphan records and duplicate records and other things that go bump in the night that you've heard campfire stories about?  Bad, bad stuff.  You can fix bugs in your code, but invalid data in the production database can be awfully dicey to clean up.
  • The doozy for me this week.   When you have performance problems, you profile the code because the performance problem may not be where you would expect it.  We have a performance problem in some new code inside a brand spanking new architecture.  We did a few (minor, it wasn't that bad) changes for performance that didn't help that much.  Then one of my coworkers used the JetBrains profiler on it and found that a 3rd party component in the mix was throwing and swallowing an exception on every single data record going through that component.  In one fell swoop we identified our performance problem.  A quick support request and we've got a patched version of the component to correct the problem.
  • Oh yeah, you know how they tell you that throwing and catching exceptions is expensive in CPU time?  Believe you me, that one's true.

About Jeremy Miller

Jeremy is the Chief Software Architect at Dovetail Software, the coolest ISV in Austin. Jeremy began his IT career writing "Shadow IT" applications to automate his engineering documentation, then wandered into software development because it looked like more fun. Jeremy is the author of the open source StructureMap tool for Dependency Injection with .Net, StoryTeller for supercharged acceptance testing in .Net, and one of the principal developers behind FubuMVC. Jeremy's thoughts on all things software can be found at The Shade Tree Developer at http://codebetter.com/jeremymiller.
This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.
  • http://www.dotnettricks.com/ Fregas

    I agree that Exceptions should NOT be used for flow control. However, I will throw custom exceptions when there is some critical thing that happens and I want the user to actually see an error. This sounds non-intuitive but it usually prevents things like bad data or bad application state because you see the custom error in development and QA and figure out how to avoid it.

  • http://codebetter.com/blogs/jeremy.miller jmiller

    jokiz, I don’t know what the component code is doing and it’s a case where I’d really like to pretend that the component doesn’t exist. If it’s using an exception for flow control I think I’ll be pretty irritated. Strange you should ask though. We’re having to do some interoperability with Java code and the Java guys seem to be much more inclined towards using exceptions as simple flow control. Besides the performance implications, I could do without that.

  • http://devpinoy.org/blogs/joeycalisay jokiz

    oops. i mean an “expected” right there

  • http://devpinoy.org/blogs/joeycalisay jokiz

    hi sir,

    is this a custom exception that you’re talking about meaning an unexpected result worked around through exception handling?