RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
Mike Thanks for the reply, can I confirm that this is only relevant to CFMX And that with CF5 there is no performance hit involved in heavy use of try catch blocks? Thanks >> -Original Message- >> From: Mike Chambers [mailto:[EMAIL PROTECTED]] >> Sent: 15 October 2002 15:31 >> To: CF-Talk >> Subject: RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE >> implemented?) >> >> 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 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.
RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
You can certainly try. :) The testing I did was on CF 5 and it seemed to produce a similar result. I'd actually be really interrested to see time results that indicate a situation in which a try-catch block is "less expensive" than any equivalent non-try-catch codeblock. > Mike > Thanks for the reply, can I confirm that this is only relevant to CFMX > And that with CF5 there is no performance hit involved in heavy use of > try catch blocks? > Thanks >>> -Original Message- >>> From: Mike Chambers [mailto:[EMAIL PROTECTED]] >>> Sent: 15 October 2002 15:31 >>> To: CF-Talk >>> Subject: RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE >>> implemented?) >>> >>> 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
Re: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
No, the ZIPs aren't common usage, but I've certainly had to deal with it a lot. Just used them to illustrate the point. Another issue with the same application was doing age ranges. Simple to type ''30 to 45'' and annoying to have to type out ''30,31,32,33...'' etc. What I'm curious about is whether something simple to code exists that can do that job with reasonable performance. There's no measurable performance hit on the client/server app, so *someone* was able to build it and make it work. That code BTW is from a product called Superbase. Mighty powerful RAD stuff that no one has ever heard of. Between pathetic promotion back when the market was still young (SB was the first native Windows DB) and Microsoft selling Access for $99 in a field where the competition was $700... it was never a volume player. A great tool, but not something you'd spend time learning unless you had to. --- Matt Robertson[EMAIL PROTECTED] MSB Designs, Inc., www.mysecretbase.com --- -- Original Message -- from: S. Isaac Dealey <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] date: Mon, 14 Oct 2002 18:20:08 -0400 >I should probably keep my nose out of this one. :) > >> Ah... this is why competition is good. > >> I don't have a new feature, per se, but I do have a pet >> peeve that came about from porting an app written in >> another language to an online CF version. > >> The CFCASE portion of CFSWITCH is sorely limited in its >> ability to handle parameters. It can't do ranges, and if >> it could it can't mix multiple parameters on the same >> line. Look at the following case argument written in >> another language: > >> SELECT CASE carval% >>CASE 1 TO 5:H6.VL = "500":H7.VL = "500" >>CASE 50001 TO 10:H6.VL = "1,000":H7.VL = "1,000" >>CASE IS > 10:H6.VL = "2,500":H7.VL = "2,500" >> END SELECT > >What's that VB? VB's the only language I'm familiar with that uses >select-case rather than switch-case ... and I've never seen ranges used in a >case statement, although I have occasionally wished that there were a method >for it... There are of course, other ways to accomplish this: > > > > > > > > > > > > > > >This is even assuming that there isn't a faster / easier way to do this in a >formulaic manner, i.e. > > > > > > > > >> 5 lines of code, total. While you could do this without >> *too* much more CF code, this is a very simple example. >> Doing U.S. ZIP code ranges, where you are selecting >> combinations of individual ZIPs and ranges - can be coded >> in a LOT fewer lines if you allow something like the >> following: > >> >> ...blahblahblah... >> >> >> ...blahblahblah... >> >> >> ...blahblahblah... >> >> > >I dunno if I'd use zip-codes as an example of common usage ... GIS is a >pretty hefty subject in and of itself. > >I suspect if I wanted to do something like this in CF I would probably wind >up using the database, structures or a 5-dimensional array ( one dimension >for each digit in the zip code ) ... most likely database ... I could write >a case statement in sql server with ranges, though that has a lot to do with >the cases in sql server ( not sure about other db servers ) being scalar >expressions (?) is that the right term?... In any event, any one of the >three solutions is liable to be more efficient than a horde of >statements as I think many of us may be apt to launch into, just because the >the structure and array solutions may not be very intuitive and the db >solution requires sql knowledge that many of us haven't mastered. > > >Isaac >Certified Advanced ColdFusion 5 Developer > >www.turnkey.to >954-776-0046 > > ~| 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 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
Since we are on a wish list, I would rather just have the ability to use variables in a case statement. Then you could do a hack like myrange=""; for(i=30; i lt 45; i=i+1){ devnull = listAppend(myrange,i,",");l } ... there have been other instance were a variable in a case would have been a life saver. -Original Message- From: Matt Robertson [mailto:[EMAIL PROTECTED]] Sent: Monday, October 14, 2002 3:36 PM To: CF-Talk Subject: Re: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?) No, the ZIPs aren't common usage, but I've certainly had to deal with it a lot. Just used them to illustrate the point. Another issue with the same application was doing age ranges. Simple to type ''30 to 45'' and annoying to have to type out ''30,31,32,33...'' etc. What I'm curious about is whether something simple to code exists that can do that job with reasonable performance. There's no measurable performance hit on the client/server app, so *someone* was able to build it and make it work. That code BTW is from a product called Superbase. Mighty powerful RAD stuff that no one has ever heard of. Between pathetic promotion back when the market was still young (SB was the first native Windows DB) and Microsoft selling Access for $99 in a field where the competition was $700... it was never a volume player. A great tool, but not something you'd spend time learning unless you had to. --- Matt Robertson[EMAIL PROTECTED] MSB Designs, Inc., www.mysecretbase.com --- -- Original Message -- from: S. Isaac Dealey <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] date: Mon, 14 Oct 2002 18:20:08 -0400 >I should probably keep my nose out of this one. :) > >> Ah... this is why competition is good. > >> I don't have a new feature, per se, but I do have a pet >> peeve that came about from porting an app written in >> another language to an online CF version. > >> The CFCASE portion of CFSWITCH is sorely limited in its >> ability to handle parameters. It can't do ranges, and if >> it could it can't mix multiple parameters on the same >> line. Look at the following case argument written in >> another language: > >> SELECT CASE carval% >>CASE 1 TO 5:H6.VL = "500":H7.VL = "500" >>CASE 50001 TO 10:H6.VL = "1,000":H7.VL = "1,000" >>CASE IS > 10:H6.VL = "2,500":H7.VL = "2,500" >> END SELECT > >What's that VB? VB's the only language I'm familiar with that uses >select-case rather than switch-case ... and I've never seen ranges used in a >case statement, although I have occasionally wished that there were a method >for it... There are of course, other ways to accomplish this: > > > > > > > > > > > > > > >This is even assuming that there isn't a faster / easier way to do this in a >formulaic manner, i.e. > > > > > > > > >> 5 lines of code, total. While you could do this without >> *too* much more CF code, this is a very simple example. >> Doing U.S. ZIP code ranges, where you are selecting >> combinations of individual ZIPs and ranges - can be coded >> in a LOT fewer lines if you allow something like the >> following: > >> >> ...blahblahblah... >> >> >> ...blahblahblah... >> >> >> ...blahblahblah... >> >> > >I dunno if I'd use zip-codes as an example of common usage ... GIS is a >pretty hefty subject in and of itself. > >I suspect if I wanted to do something like this in CF I would probably wind >up using the database, structures or a 5-dimensional array ( one dimension >for each digit in the zip code ) ... most likely database ... I could write >a case statement in sql server with ranges, though that has a lot to do with >the cases in sql server ( not sure about other db servers ) being scalar >expressions (?) is that the right term?... In any event, any one of the >three solutions is liable to be more efficient than a horde of >statements as I think many of us may be apt to launch into, just because the >the structure and array solutions may not be very intuitive and the db >solution requires sql knowledge that many of us haven't mastered. > > >Isaac >Certified Advanced ColdFusion 5 Developer > >www.turnkey.to >954-776-0046 > > ~| 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
RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
This kind of functionality would basically make null and void what Jochem had mentioned about SWITCH statements being faster than a series of IF-ELSEs. He had suggested that SWITCH could be faster because only a single expression needs to be evaluated whereas with the IFs, multiple expressions need to be evaluated. Adding support for variables to CASEs would negate that. All that said, I wonder if the speed improvement is anything more than negligible. I mean, what's the largest IF-ELSE or SWITCH statement that anyone has had to write? For something with only a few options (say 2-30) I wonder if we'd really notice the speed improvement. For something with a ton of options, it'd probably be better to find a different way of doing it (kind of like what Issac was saying). -- Mosh Teitelbaum evoch, LLC Tel: (301) 625-9191 Fax: (301) 933-3651 Email: [EMAIL PROTECTED] WWW: http://www.evoch.com/ > -Original Message- > From: Rob Rohan [mailto:[EMAIL PROTECTED]] > Sent: Monday, October 14, 2002 6:48 PM > To: CF-Talk > Subject: RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE > implemented?) > > > Since we are on a wish list, I would rather just have the ability to use > variables in a case statement. Then you could do a hack like > > > myrange=""; > for(i=30; i lt 45; i=i+1){ > devnull = listAppend(myrange,i,",");l > } > > > > > ... > > > there have been other instance were a variable in a case would have been a > life saver. > > > -Original Message----- > From: Matt Robertson [mailto:[EMAIL PROTECTED]] > Sent: Monday, October 14, 2002 3:36 PM > To: CF-Talk > Subject: Re: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE > implemented?) > > > No, the ZIPs aren't common usage, but I've certainly had to deal with it a > lot. Just used them to illustrate the point. Another issue with the same > application was doing age ranges. Simple to type ''30 to 45'' > and annoying > to have to type out ''30,31,32,33...'' etc. > > What I'm curious about is whether something simple to code exists that can > do that job with reasonable performance. There's no measurable > performance > hit on the client/server app, so *someone* was able to build it > and make it > work. > > That code BTW is from a product called Superbase. Mighty > powerful RAD stuff > that no one has ever heard of. Between pathetic promotion back when the > market was still young (SB was the first native Windows DB) and Microsoft > selling Access for $99 in a field where the competition was $700... it was > never a volume player. A great tool, but not something you'd spend time > learning unless you had to. > > --- > Matt Robertson[EMAIL PROTECTED] > MSB Designs, Inc., www.mysecretbase.com > --- > > > -- Original Message -- > from: S. Isaac Dealey <[EMAIL PROTECTED]> > Reply-To: [EMAIL PROTECTED] > date: Mon, 14 Oct 2002 18:20:08 -0400 > > >I should probably keep my nose out of this one. :) > > > >> Ah... this is why competition is good. > > > >> I don't have a new feature, per se, but I do have a pet > >> peeve that came about from porting an app written in > >> another language to an online CF version. > > > >> The CFCASE portion of CFSWITCH is sorely limited in its > >> ability to handle parameters. It can't do ranges, and if > >> it could it can't mix multiple parameters on the same > >> line. Look at the following case argument written in > >> another language: > > > >> SELECT CASE carval% > >>CASE 1 TO 5:H6.VL = "500":H7.VL = "500" > >>CASE 50001 TO 10:H6.VL = "1,000":H7.VL = "1,000" > >>CASE IS > 10:H6.VL = "2,500":H7.VL = "2,500" > >> END SELECT > > > >What's that VB? VB's the only language I'm familiar with that uses > >select-case rather than switch-case ... and I've never seen > ranges used in > a > >case statement, although I have occasionally wished that there were a > method > >for it... There are of course, other ways to accomplish this: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > >This is even assuming that there isn't a faster / easier way to > do this in > a > >formulaic manner, i.e. > > > > >
Re: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
> No, the ZIPs aren't common usage, but I've certainly had > to deal with it a lot. Just used them to illustrate the > point. Another issue with the same application was doing > age ranges. Simple to type ''30 to 45'' and annoying to > have to type out ''30,31,32,33...'' etc. Yea, I'd probably wind up going with sql, structures, arrays or even just for something like this... > That code BTW is from a product called Superbase. Mighty > powerful RAD stuff that no one has ever heard of. Between > pathetic promotion back when the market was still young > (SB was the first native Windows DB) and Microsoft selling > Access for $99 in a field where the competition was > $700... it was never a volume player. A great tool, but > not something you'd spend time learning unless you had to. I've heard of it... Never used it... Probably largely for the reasons described here as Access was a competitor and I have used Access... Of course, I've not used FoxPro either... Isaac Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 ~| 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
RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
> Since we are on a wish list, I would rather just have the > ability to use variables in a case statement. Then you > could do a hack like > > myrange=""; > for(i=30; i lt 45; i=i+1){ > devnull = listAppend(myrange,i,",");l > } > > > > ... > > there have been other instance were a variable in a case > would have been a life saver. My suspicion is that this wasn't done for reasons of both performance and clarity. Not that we can't create horrendous, impossible to read code anyway, but I can imagine that case statements with variables could become very confusing very fast. There is another way to simulate variables or ranges in a case statement with a cftry and cfcatch blocks... ... default case stuff here ... ... do stuff... ... do stuff... ... do stuff... Of course, if you want to reduce the amount of typing here, you can eliminate the message in your tags and throw different custom types and then use a in place of each case statement, i.e. ... default case stuff here ... ... do stuff... ... do stuff... ... do stuff... It's more typing than the sure, but not insurmountable, and it allows you to perform additional processing between your if / case statements, which isn't available to you with a standard switch-case structure iirc. I've used try catch for a number of non-error handling items .. properly implemented, it works pretty well. Or at least it has for me. I'm not sure, but I think you might also be able to get away with using variables in the type attribute of your cfcatch tags... I've never tested this tho, so I'm not sure. How about this for an age range issue? My age is unknown between 16 and 20 between 21 and 35 Now that's not too terribly far off from the equivalent cfswtich statement is it? ... Granted, you could accomplish something similar with this: My age is between 16 and 20 between 21 and 35 unknown And this is much shorter, however, with the try block, you can do all kinds of crazy stuff in the in-between parts... I'm a old bastard and the line belongs in the middle of my car #cfcatch.message# This is roughly equivalent to the cfscript switch-case functionality which allows you to cascade your case statements by leaving out the break; statement at the end of a case block. The only thing that's a bit counterintuitive about this approach ( at least the only thin I find counterintuitive about it ) is that your default case is in the middle instead of at the end... Though you could remedy this by having a final in the middle and a final with another custom type at the bottom. Anyway... I've gone on and on... I think I'll let it drop here... Isaac Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 ~| 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 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
Yeah, that is a good point. The times I would like to use it the most are more like in situations where ... -Original Message- From: S. Isaac Dealey [mailto:[EMAIL PROTECTED]] Sent: Monday, October 14, 2002 5:13 PM To: CF-Talk Subject: RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?) > Since we are on a wish list, I would rather just have the > ability to use variables in a case statement. Then you > could do a hack like > > myrange=""; > for(i=30; i lt 45; i=i+1){ > devnull = listAppend(myrange,i,",");l > } > > > > ... > > there have been other instance were a variable in a case > would have been a life saver. My suspicion is that this wasn't done for reasons of both performance and clarity. Not that we can't create horrendous, impossible to read code anyway, but I can imagine that case statements with variables could become very confusing very fast. There is another way to simulate variables or ranges in a case statement with a cftry and cfcatch blocks... ... default case stuff here ... ... do stuff... ... do stuff... ... do stuff... Of course, if you want to reduce the amount of typing here, you can eliminate the message in your tags and throw different custom types and then use a in place of each case statement, i.e. ... default case stuff here ... ... do stuff... ... do stuff... ... do stuff... It's more typing than the sure, but not insurmountable, and it allows you to perform additional processing between your if / case statements, which isn't available to you with a standard switch-case structure iirc. I've used try catch for a number of non-error handling items . properly implemented, it works pretty well. Or at least it has for me. I'm not sure, but I think you might also be able to get away with using variables in the type attribute of your cfcatch tags... I've never tested this tho, so I'm not sure. How about this for an age range issue? My age is unknown between 16 and 20 between 21 and 35 Now that's not too terribly far off from the equivalent cfswtich statement is it? ... Granted, you could accomplish something similar with this: My age is between 16 and 20 between 21 and 35 unknown And this is much shorter, however, with the try block, you can do all kinds of crazy stuff in the in-between parts... I'm a old bastard and the line belongs in the middle of my car #cfcatch.message# This is roughly equivalent to the cfscript switch-case functionality which allows you to cascade your case statements by leaving out the break; statement at the end of a case block. The only thing that's a bit counterintuitive about this approach ( at least the only thin I find counterintuitive about it ) is that your default case is in the middle instead of at the end... Though you could remedy this by having a final in the middle and a final with another custom type at the bottom. Anyway... I've gone on and on... I think I'll let it drop here... Isaac Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 ~| 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 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
Re: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
On Monday, Oct 14, 2002, at 17:13 US/Pacific, S. Isaac Dealey wrote: > There is another way to simulate variables or ranges in a case > statement > with a cftry and cfcatch blocks... try/catch is a pretty heavy operation - you should only use it for (unexpected) error cases, not normal operation... How about: > > > > ... default case stuff here ... > > ... do stuff... > ... do stuff... > ... do stuff... > > I've used try catch for a number of non-error handling items > .. properly implemented, it works pretty well. Or at least it has for > me. Have you timed it? (I won't even start on the stylistic implications of this!) > And this is much shorter, however, with the try block, you can do all > kinds > of crazy stuff in the in-between parts... Yes, well, we won't talk about that Isaac, eh? I'll just call for those nice men in their white coats... :) "I have always wished that my computer would be as easy to use as my telephone. My wish has come true - I no longer know how to use my telephone." -- Bjarne Stroustrup ~| 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 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
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 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm
Re: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
> On Monday, Oct 14, 2002, at 17:13 US/Pacific, S. Isaac > Dealey wrote: >> There is another way to simulate variables or ranges in a >> case statement with a cftry and cfcatch blocks... > try/catch is a pretty heavy operation - you should only > use it for (unexpected) error cases, not normal operation... I guess I > How about: > >> > caseval="1"> >> > caseval="2"> >> > caseval="3"> >> ... default case stuff here ... >> >> ... do stuff... >> ... do stuff... >> ... do stuff... >> >> I've used try catch for a number of non-error handling >> items >> .. properly implemented, it works pretty well. Or at >> least it has for >> me. > Have you timed it? (I won't even start on the stylistic > implications of > this!) >> And this is much shorter, however, with the try block, >> you can do all >> kinds >> of crazy stuff in the in-between parts... > Yes, well, we won't talk about that Isaac, eh? I'll just > call for those > nice men in their white coats... :) > "I have always wished that my computer would be as easy to > use as my > telephone. > My wish has come true - I no longer know how to use my > telephone." > -- Bjarne Stroustrup > ~~ > ~~~| > Archives: > http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 > Subscription: http://www.houseoffusion.com/index.cfm?sideb > ar=lists&body=lists/cf_talk > FAQ: http://www.thenetprofits.co.uk/coldfusion/faq > Signup for the Fusion Authority news alert and keep up > with the latest news in ColdFusion and related topics. > http://www.fusionauthority.com/signup.cfm Isaac Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 ~| 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 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.
Re: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
damn keyboard shortcuts... >> I've used try catch for a number of non-error handling >> items .. properly implemented, it works pretty well. Or at >> least it has for me. > > Have you timed it? (I won't even start on the stylistic > implications of this!) I guess I probably should explicitely time test them... I'll probably do something on that a bit later today... >> And this is much shorter, however, with the try block, >> you can do all kinds of crazy stuff in the in-between parts... > Yes, well, we won't talk about that Isaac, eh? I'll just > call for those nice men in their white coats... :) Sometimes... :) Isaac Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 ~| 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 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.
RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
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
Re: try-catch was RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
On Tuesday, Oct 15, 2002, at 17:26 US/Pacific, S. Isaac Dealey wrote: > Isaac the Butcher of Fusion ... :) Careful, that might stick! :) [horrific factorial implemented with try/catch snipped] > Of course not... For starters, there are existing UDF's on cflib.org to > handle factorials. :P And I'm not certain the syntax is correct, but > then > it's MX and I haven't gotten to the new version yet, so I wouldn't > know. :) Oh, don't worry - I tried it out first to make sure it ran :) :) > lol... That's priceless -- most of that stuff is lame, but that first > mittens anim. is hillarious... Incidentally, one of the answers from > the > Magic 8 Ball is "Tell people you can smell their brains, it's a good > ice > breaker at parties." Yes, I was at BACFUG one evening wearing my "Mittens' face" T shirt (no writing on it) and a voice behind me said "I can smell your brains". It's a small world. The animator is a very good friend of mine back in the UK. He is totally barking :) "Conform! Consume! Obey!" -- Mr Snaffleburger : http://www.matazone.co.uk/theotherside.html ~| 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 Structure your ColdFusion code with Fusebox. Get the official book at http://www.fusionauthority.com/bkinfo.cfm
Re: try-catch was RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
> On Tuesday, Oct 15, 2002, at 17:26 US/Pacific, S. Isaac > Dealey wrote: >> Isaac the Butcher of Fusion ... :) > Careful, that might stick! :) At least then I'd be assured a reputation. :) > [horrific factorial implemented with try/catch snipped] >> Of course not... For starters, there are existing UDF's >> on cflib.org to handle factorials. :P And I'm not certain >> the syntax is correct, but then it's MX and I haven't >> gotten to the new version yet, so I wouldn't know. :) > Oh, don't worry - I tried it out first to make sure it ran > :) :) Yech... I pitty your server. :P >> lol... That's priceless -- most of that stuff is lame, >> but that first mittens anim. is hillarious... Incidentally >> one of the answers from the Magic 8 Ball is "Tell people you >> can smell their brains, it's a good ice breaker at parties." > Yes, I was at BACFUG one evening wearing my "Mittens' face" > T shirt (no writing on it) and a voice behind me said "I can > smell your brains". It's a small world. The animator is a > very good friend of mine back in the UK. He is totally > barking :) Barking's good. :) I really like the Mr Snaffleburger sketches... Though it fits well with my hippie anti-commercialism/anti-consumerism schtick. :) Mr Snaffleburger is confused because he doesn't know the meaning of rebellion in a society where all forms of expression are mitigated by consumption. And Mr Snaffleburger's [x] is broken. Well, let's go shopping and get you a new one. Shopping good. Isaac Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 ~| 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
Re: try-catch was RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
On Wednesday, Oct 16, 2002, at 06:13 US/Pacific, S. Isaac Dealey wrote: >> [horrific factorial implemented with try/catch snipped] > Yech... I pitty your server. :P My Mac laptop, you mean? :) In answer to Kola's question about try-catch in CF5: try-catch generally introduces an overhead in every single language in which it is implemented... C++, Java, CFML. It's just a fact of how it works. Which is why it should mostly be used for 'unexpected' error situations. throw-catch has to be implemented by some sort of runtime "lookup & compare" operation that will always be slower than simply setting variables or returning an error code from a function (and testing the value in both cases). An implementation can be more or less efficient in the way it implements throw-catch but it will always be a fairly heavy operation. "Conform! Consume! Obey!" -- Mr Snaffleburger : http://www.matazone.co.uk/theotherside.html ~| 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 Signup for the Fusion Authority news alert and keep up with the latest news in ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm
RE: try-catch was RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
Thanks Mesh, I suppose I should clarify by saying that I haven't simply disregarded the original intent of 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 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 within a loop, I'm also using 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
Re: try-catch was RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
On Tuesday, Oct 15, 2002, at 07:51 US/Pacific, S. Isaac Dealey wrote: > I suppose I should clarify by saying that I haven't simply disregarded > the > original intent of 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. Although I would maintain that you would 'expect' user input to contain errors (and therefore this is not an 'ideal' use of try/catch), I would also concede that try/catch can make this sort of validation easier and interacting with a user for error handling is much less performance critical. > There have been a handful ( maybe a half dozen ) situations where I > found > the 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. Yes, that is true. There are extenuating circumstances for most abuses of a language :) I'm sure you wouldn't even consider doing this: factorial #url.n# is #cfcatch.message# "I can smell your brains!" -- Mittens the Kitten : http://www.matazone.co.uk/theotherside.html ~| 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
Re: try-catch was RE: switch-case was RE: BlueDragon (was RE: How is CFMX J2EE implemented?)
>> There have been a handful ( maybe a half dozen ) >> situations where I found >> the 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. > Yes, that is true. There are extenuating circumstances for > most abuses of a language :) Isaac the Butcher of Fusion ... :) > I'm sure you wouldn't even consider doing this: > > > > > > > > > > > > > > > > > > > > factorial #url.n# is #cfcatch.message# > > > Of course not... For starters, there are existing UDF's on cflib.org to handle factorials. :P And I'm not certain the syntax is correct, but then it's MX and I haven't gotten to the new version yet, so I wouldn't know. :) > "I can smell your brains!" > -- Mittens the Kitten : > http://www.matazone.co.uk/theotherside.html lol... That's priceless -- most of that stuff is lame, but that first mittens anim. is hillarious... Incidentally, one of the answers from the Magic 8 Ball is "Tell people you can smell their brains, it's a good ice breaker at parties." Isaac Certified Advanced ColdFusion 5 Developer www.turnkey.to 954-776-0046 ~| 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 This list and all House of Fusion resources hosted by CFHosting.com. The place for dependable ColdFusion Hosting.