Claude Schneegans wrote:
>  >>It seems to use the power of CF more.
> 
> It may be, but is it really what  makes "good code"?
> 
> The first code is more intuitive , logical and it corresponds to the 
> real situation.
> It explains more clearly the two situations that can be encountered.
> The second code leads to think that the second case is an error of the 
> first, which is not true.
> And BTW, the first code could still be embeded inside a CFTRY to handle 
> true errors, ...
> and use all the power of CF! ;-)
> 

Also, the use of try/catch in this way is generally not so great because 
you could "catch" more than you bargained for.
Using the if, you're testing for a very specific condition that you can 
anticipate and handle.
With the catch, you will not only catch the exception you expect, but 
anything else which you don't expect, which you probably should be 
letting get thrown up to the caller rather than be caught.

In general, when dealing with exceptions, you should catch only that 
which you expect and can deal with, anything else should be allowed to 
be thrown up to the caller which may understand the context of the 
exception better, and so be better equipped to handle it.

Obviously in this simple example, there isn't much else that could go 
wrong to cause an exception to be thrown, but it's something to keep in 
mind.

-- 
---------------------------------------------------------------------
Chris Jensen [EMAIL PROTECTED]

Educational Experience (Australia)
Postal Address: PO Box 860, Newcastle NSW 2300
Freecall:       1-800-025 270      International: +61-2-4923 8222
Fax:            (02) 4942 1991     International: +61-2-4942 1991

Visit our online Toy store! http://www.toysandmore.com.au/
---------------------------------------------------------------------


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192278
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to