|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Best practices
Hi FolksRob Voyle 06/19/12 07:20 P Years ago it was much more performant to use the single tag wrapped aroundMatt Quackenbush 06/19/12 07:26 P Matt's dead on. It really doesn't matter very much, anymore. It's a styleNathan Strutz 06/19/12 09:53 P Everything between cfoutput tags needs to be parsed. So a big page wouldRuss Michaels 06/20/12 03:20 A > Everything between cfoutput tags needs to be parsed. So a bigJustin Scott 06/20/12 12:21 P > > Everything between cfoutput tags needs to be parsed. So a bigDave Watts 06/20/12 01:10 P > While the general statement you made about bytecode is true, theJustin Scott 06/20/12 02:16 P Hi folksRob Voyle 06/20/12 06:06 P If I wrap a large amount of code in cfoutput tags, I always commentMaureen 06/20/12 06:18 P And, IMO, there's a point too often overlooked: commenting and style (as in indenting code and naming stuff).Stephens, Larry V 06/21/12 09:27 A > I recently had to help with some code with really outlandish variable and field names.Dave Watts 06/21/12 09:47 A > I recently had to help with some code with reallyJustin Scott 06/21/12 12:08 P Even worse is when they copy code directly from tutorials and haveMaureen 06/21/12 05:22 P If you use cfsetting show output only (cant recall attribute)AJ Mercer 06/19/12 07:43 P Hi Folks I am wondering what is considered best practices for the <cfoutput> tag I have a large page many tables, paragraphs etc. that has text and a series of variables scattered thru it. The simplest coding is to put a <cfoutput> at the begining and a </cfoutput> at the end and us #variable# thru the page or should I use a separate <cfoutput>#variable#</cfoutput> for each new variable. Thanks Rob Robert J. Voyle, Psy.D. Director, Clergy Leadership Institute For Coaching and Training in Appreciative Inquiry Author: Restoring Hope: Appreciative Strategies to Resolve Grief and Resentment http://www.appreciativeway.com/ 503-647-2378 or 503-647-2382 Years ago it was much more performant to use the single tag wrapped around everything. Nowadays it is kinda more about personal preference than performance. HTH Sent from my Samsung Galaxy SII On Jun 19, 2012 6:20 PM, "Rob Voyle" <robvoyle@voyle.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- Matt's dead on. It really doesn't matter very much, anymore. It's a style preference. That said, I would add that style is very important! The ability to scan a file and know what it's doing without guessing is an important thing. Having templates that match and create a cohesive feeling application is also important. With that, I'd say wrapping entire templates is ok so long as you don't force a lot of double-## escaping characters, because that looks ugly. Try to keep CFML out of your javascript except where it's necessary, because that looks ugly. Same for stylesheets, because ID selectors get double-hash marks, which removes you from your context. nathan strutz [www.dopefly.com] [hi.im/nathanstrutz] [about.me/nathanstrutz] On Tue, Jun 19, 2012 at 4:25 PM, Matt Quackenbush <quackfuzed@gmail.com>wrote: ----- Excess quoted text cut - see Original Post for more ----- Everything between cfoutput tags needs to be parsed. So a big page would slow performance, by how much is prob negligible but worth testing to find out. If there are only a few vars in the whole page then only putting the cfoutput where needed will speed things up. Depends how important those milliseconds are to you. Regards Russ Michaels On Jun 20, 2012 2:52 AM, "Nathan Strutz" <strutz@gmail.com> wrote: ----- Excess quoted text cut - see Original Post for more ----- > Everything between cfoutput tags needs to be parsed. So a big > page would slow performance, by how much is prob negligible > but worth testing to find out. Remember that this would only be a hit once each time the file was changed, as once it's compiled down to bytecode it doesn't have to be parsed again. Back in the CF5 days the code was parsed with each page view, but that hasn't been the case since CFMX 6. -Justin ----- Excess quoted text cut - see Original Post for more ----- While the general statement you made about bytecode is true, the conclusion you draw from it is one that I'd be reluctant to make without load testing. CF still has to substitute values for expressions in your CFOUTPUT blocks, and we don't know whether the cost of multiple CFOUTPUTs vs single, larger CFOUTPUTs is a compilation cost or an execution cost. At least, I don't know, and I've never seen any real evidence one way or the other. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or onsite > While the general statement you made about bytecode is true, the > conclusion you draw from it is one that I'd be reluctant to make > without load testing. Indeed, I had this debate with someone a few years ago and we beat a server into the ground for a few hours with both scenarios and the results were essentially the same either way. I don't have the exact numbers anymore, but it was along the lines of a difference of less than 10ms when the results of millions of iterations were averaged out (that was on ColdFusion 8 Enterprise on a Dell PowerEdge 2850 server if memory serves). I remember this being a big deal back in 1999 under CF4, but in current versions it doesn't appear to matter from a performance standpoint which cfoutput approach is used. -Justin Scott Hi folks Thanks for the input and help. I had not been thinking in terms of speed but of accuracy, which doesn't seem to be an issue. The page isn't that big that speed is going to be a problem. It is actually much easier to code without the <output> as I have several paragraphs with variable scattered throughout. Thanks Rob Robert J. Voyle, Psy.D. Director, Clergy Leadership Institute For Coaching and Training in Appreciative Inquiry Author: Restoring Hope: Appreciative Strategies to Resolve Grief and Resentment http://www.appreciativeway.com/ 503-647-2378 or 503-647-2382 If I wrap a large amount of code in cfoutput tags, I always comment the starting and ending tags to describe what they wrap. It makes it easier to match them when debugging. ----- Excess quoted text cut - see Original Post for more ----- And, IMO, there's a point too often overlooked: commenting and style (as in indenting code and naming stuff). I've sometimes been weak about comments in my code - but I'm trying to do better. I have trouble remembering what I was trying to do when I revisit code after a few months, let alone looking at someone else's code. And while I'll buy that some code is self-documenting I don't buy that on a much grander scale than a half-dozen lines or so. I am insistent that and code written for my department be properly indented and that includes javascript (and I don't mean online libraries). I'm willing to give up the fractional difference in load or execution time for code I can decipher without developing ulcers. I recently had to help with some code with really outlandish variable and field names. <cfset mawkishbbt = GNOME.barakish> (not really, but a good paraphrase) Name stuff so the next person that looks at the code has a clue what you're doing. If I wrap a large amount of code in cfoutput tags, I always comment the starting and ending tags to describe what they wrap. It makes it easier to match them when debugging. ----- Excess quoted text cut - see Original Post for more ----- > I recently had to help with some code with really outlandish variable and field names. > <cfset mawkishbbt = GNOME.barakish> (not really, but a good paraphrase) I've been telling this story to students for I guess around ten years now. I've done quite a bit of work reviewing other people's apps, and suggesting improvements or fixing problems, etc. Once, I was hired by a company, that in the peak craziness of the dotcom era had bought some sort of forum for developers - kind of like StackOverflow in concept. Anyway, it was having performance and scaling problems once people actually started using it, and that's why they hired me. The app had been developed by a single person, who I was told lived in a shack in the woods and was very hard to reach, so I was never able to talk to him. Anyway, all the variables throughout the program were named after characters from "The Lion King". Of course, the program had nothing to do with the movie, I guess when you live in a shack in the woods writing code this is the kind of thing you do. I ended up having to write a "cast of characters" which mapped to what the variables actually did: Application.Simba - number of logged-in users ... I reported all this to the client, of course, but I don't know if the developer ever suffered any negative repercussions - other than being the butt of my jokes in the hundreds of CF classes I've taught since. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ http://training.figleaf.com/ Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on GSA Schedule, and provides the highest caliber vendor-authorized instruction at our training centers, online, or ons > I recently had to help with some code with really > outlandish variable and field names. > <cfset mawkishbbt = GNOME.barakish> (not really, but a good paraphrase) That reminds me of my days writing vScript for the Virtual Advanced BBS (way back in 1995) where all of the variables were predefined based on letters and numbers, so: a0, a1 ... z8, z9. Talk about torture... and you'd better not need more than 260 of them in any one script either. Shudder. -Justin Even worse is when they copy code directly from tutorials and have names like myTable, myQuery, myForm, foo and bar. On Thu, Jun 21, 2012 at 9:08 AM, Justin Scott <leviathan@darktech.org> wrote: > > That reminds me of my days writing vScript for the Virtual Advanced > BBS (way back in 1995) where all of the variables were predefined > based on letters and numbers, so: a0, a1 ... z8, z9. Talk about > torture... and you'd better not need more than 260 of them in any one > script either. Shudd If you use cfsetting show output only (cant recall attribute) You have to wrap html in cfoutput tags On Jun 20, 2012 7:20 AM, "Rob Voyle" <robvoyle@voyle.com> wrote: ----- Excess quoted text cut - see Original Post for more -----
|
June 19, 2013
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||