Exceptional Circumstances
Jun. 1st, 2005 10:33 pmSome 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.
(no subject)
Date: 2005-06-02 06:48 am (UTC)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.
(no subject)
Date: 2005-06-02 03:08 pm (UTC)