On 8/22/02 at 8:54 AM -0700, Will Leshner wrote:
On Thursday, August 22, 2002, at 07:32 AM, Randall Meadows wrote:
<RB-newbie/OO-novice>
Would it not be better form to throw and exception in this case,
instead of returning nil? In my mind, there is a subtly different,
but important, distinction between the two.
</>
Throwing an exception is an interesting idea. My "gut" tells me no,
but I don't know why. It would certainly solve the problem.
I had a hard time articulating it, too, that's why I didn't
elaborate, but since you brought it up again..
I know I still haven't completely formulated this reasoning, but here
goes: There are instances where returning nil is acceptable, and
possibly expected as a valid answer. However, an exception is a
definite indicator of a real problem that is never supposed to
occur[1] and would be caught by the developer anyway, long before the
code is released (presumably).
[1] Despite the fact that I have, on several occasions, written
"throw(noErr);" and caught it just several lines later, merely to
avoid having to duplicate clean-up code.
--
randy
To see the two cutest kids ever, visit <http://www.not-pc.com/>
In a world without walls and fences who needs windows or gates?
|