I have to disagree with you on this one, Hal (and Sean). While you're right, a person not having a spouse isn't an exceptional condition, asking a person to give you a reference to their non-existant spouse is. Say you're single, and someone asks for your spouse's email address. Are you going to give them a "marker" email address, null, or say "I don't have a spouse"? I suspect the third. Now if that same someone had first asked if you had a spouse (and you said "no"), they never would have asked for your spouse's email address, and the exceptional condition wouldn't have occurred.
However, while we disagree about using exceptions for this, I do agree that the conditions where an exception is raised should be preventable by intelligent users (and by users, I mean calling code). So someone can do: <cfif obj.doesUserExist()> <cfset user = obj.getUser() /> .. do something .. <cfelse> .. handle missing user .. </cfif> If they just blindly do the first block lines (2 and 3), that's also 'acceptable'. Not ideal, of course, since if the user doesn't exist, a UserNotFoundException (or whatver) will be thrown, but it'll be a lot better for that to happen than for a "method not found" exception, or a "can't deference scalar value" error, which is what you'd get with some random non-user return value. At the very least, you'd get an NPE, but since CF doesn't have nulls (aside from the hack you outlined, Sean), you can hardly expect a CF developer to look at an NPE as anything except a bug in CF (which is the right conclusion, if you ask me). cheers, barneyb On 10/23/05, Hal Helms <[EMAIL PROTECTED]> wrote: > I agree, Vince. I think exceptions should be for just that: exceptional > conditions. A person not having a spouse, a library book not having a > lendee, etc. are not exceptional conditions. Throwing an exception in such a > non-exceptional case is, IMHO, pretty dubious. > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 100 invites. ---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). CFCDev is supported by New Atlanta, makers of BlueDragon http://www.newatlanta.com/products/bluedragon/index.cfm An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
