You are viewing bcholmes

Previous Entry | Next Entry

Exceptional Circumstances

default

Some time ago, someone I know was showing me some Python code, trying to convince me that I should give a damn about Python. One of the things I found a little off-putting was Python's use of exceptions. Like this:

    try:
      for blah in something.getBlahs():
        if ...someCondition...:
          raise Found
    except Found:
      ...

I found it quite odd that someone would use an exception in this case, given that, y'know, it's not really an exceptional case. To be honest, I've never been too fond of exceptions, thinking them pretty much the equivalent of a goto. Generally, I reserve exceptions for cases that are real programming errors, or infrastructure failures. That's exceptional.

I think this article articulates a lot of what bothers me with exceptions: that, often, a piece of code that has considered the impact of exceptions is indistinguishable from a piece of code that hasn't considered the impact of exceptions.

That's a real maintainability problem, y'know. If you can't rely on the eyes of another programmer to see a particular problem, then you've made the problem harder to adequately manage. This article by "Joel on Software" really addresses this idea well.

Comments

( 2 comments — Leave a comment )
jennyaxe
Jun. 2nd, 2005 06:48 am (UTC)
Thanks a lot for those two links!

I'm in a new job, where part of my time will be spent redesigning and implementing a system that's currently in production though it's really proof-of-concept-level instead of production-level. And while I do know how to write code, it's been a while since I had a project of this size to design myself. Not that it's very big, but I really really want to do it right. And the latter link gave me some hints that'll come in very handy.
king_tirian
Jun. 2nd, 2005 03:08 pm (UTC)
Very interesting reading. I knew that I liked Hungarian notation and was annoyed that every C# reference book seems specifically crafted to stamp out its use. Spolsky's article helped me to see why my feelings were not wholly irrational.
( 2 comments — Leave a comment )

Latest Month

May 2013
S M T W T F S
   1234
567891011
12131415161718
19202122232425
262728293031 

Tags

Powered by LiveJournal.com
Designed by Tiffany Chow