Thanks Mesh,

I suppose I should clarify by saying that I haven't simply disregarded the
original intent of <cftry> all-together. I do use it mostly for error
handling, although much of it is for custom error handling, such as server
side form validation. In most cases I use it no more than once on a given
page, and with the possible acception of the afforementioned form validation
example, usually on reasonably low-volume pages.

There have been a handful ( maybe a half dozen ) situations where I found
the <cftry> was extremely helpful in creating an easily human read/writeable
codeblock where the only alternative I could think of would have been a
horrible mess of spaghetti code.

Also iirc, in any situation where I'm using <cftry> within a loop, I'm also
using <cfflush> to push output to the browser, usually for a custom progress
bar to let the user know how far along they are in their process. These
long-running processes are low-traffic administrative features, and the
try-catch in any that I can think of is logging errors to the database for
later review, which in addition to associating the error with information
specific to the application/database in question, also allows business users
who wouldn't have access to the ColdFusion administrator to see these error
logs and potentially fix their own problems. So any added overhead in these
situations specifically is being managed and isn't without significant
purpose.

I've heard before that try-catch blocks can be heavy, but I've never
explicitely time tested them as compared to alternative codeblocks to
accomplish the same task(s). They are a last resort in my case, but I don't
automatically disregard them as an option simply because I've heard they're
heavy.


S. Isaac Dealey
Certified Advanced ColdFusion 5 Developer

www.turnkey.to
954-776-0046

> The try isn't too expensive, but the catch can be. However, running a
> bunch of trys within a loop can also degrade performance.

> The catch generates significant overhead when an exception is thrown
> because a copy of the stack has to be created.

> a quick search of google turns up:

> http://www.javaworld.com/javaworld/javaqa/2001-07/04-qa-0727-try.html

> http://ccm.redhat.com/doc/core-platform/5.0/engineering-standards/perfor
> mance-optimization.html#Exceptions

> there is also a good discussion of it in:

> Java Performance Tuning published by O'Reilly.

> In general, you should not use try / catch for flow control.

> hope that helps...

> mike chambers

> [EMAIL PROTECTED]


>> -----Original Message-----
>> From: Kola Oyedeji [mailto:[EMAIL PROTECTED]]
>> Sent: Tuesday, October 15, 2002 4:33 AM
>> To: CF-Talk
>> Subject: RE: switch-case was RE: BlueDragon (was RE: How is
>> CFMX J2EE implemented?)
>>
>>
>> Hi
>>
>> Sean, have I missed something, are you saying try and catch add a
>> significant performance overhead?
>>
>>
>> Thanks
>>
>> Kola
>>
>> >> -----Original Message-----
>> >> From: Sean A Corfield [mailto:[EMAIL PROTECTED]]
>> >> Sent: 15 October 2002 02:08
>> >> To: CF-Talk
>> >> Subject: Re: switch-case was RE: BlueDragon (was RE: How
>> is CFMX J2EE
>> >> implemented?)
>> >>
>> >>
>> >> try/catch is a pretty heavy operation - you should only use it for
>> >> (unexpected) error cases, not normal operation...
>> >>
>>
>>
>>
>>
> 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Get the mailserver that powers this list at http://www.coolfusion.com

Reply via email to