RE: better way to code?
In my own work all my display is generated using the onTap framework's html library. Generally speaking my conditional logic doesn't appear within html. Instead the conditional logic may be used to "build" (x)html which is then displayed. I might have something like this (pseudocode): Home Admin XXX Then in my display template I have #htlib.show(request.menu)# Between these two bits of code if I want to remove the admin link, I can use something like this > Calvin > Depends, In most cases you can do any conditional logic > before rendering > your page but obviously there are exceptions such as when > the result of the > condition determines what html is being displayed (and not > something else > such as if the user should be redirected or a session > variable should be > updated etc.) Some frameworks allow you to determine the > portions of a page > being rendered before the page is assembled allowing you > to decide what > portions are shown before they are rendered. > Just my 2pence > Kola >> -Original Message- >> From: Calvin Ward [mailto:[EMAIL PROTECTED] >> Sent: 31 January 2005 13:50 >> To: CF-Talk >> Subject: RE: better way to code? >> >> In light of this discussion, how about lots of cfif >> statements buried in >> html...? s. isaac dealey 954.927.5117 new epoch : isn't it time for a change? add features without fixtures with the onTap open source framework http://macromedia.breezecentral.com/p49777853/ http://www.sys-con.com/story/?storyid=44477&DE=1 http://www.sys-con.com/story/?storyid=45569&DE=1 http://www.fusiontap.com ~| 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:192887 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
Re: better way to code?
Johnny Le wrote: > There is a discussion right now in CF-Jobs-Talk called "Indian Code". It says > "I mentioned to the client that the code looked like it was done by a first > month CF programmer. You know the type, pound signs everywhere, lots of CFIFs, > etc. Didn't say the code sucked or anything, just that it looked amaturish." > I tend to agree with this statement. Somehow beginners tends to use more > CFIFs > than the experts. Have you attend any of Hal Helm's or some of the experts' > presentations? Their code seems to have a lot less CFIFs and more CFSET. > They > just seem to organize things better. I don't want to turn this into a big > discussion here. If you have some tricks or tips to help me code better, make > good/better code, I'll greatly appreciate it. Avoid special cases. That's all it is. That's the only reason why code with lots of conditional statements look's amateurish. For some reason, rather than trying to find the underlying logical flow of data, amateurs tend to treat things as a set of special cases. One of my favourite exampes is from the book "Writing Solid Code". It's in C, but you should be able to understand it. It's a little simplified, but it gets the point across. The code is meant to control a type of checkbox. The checkbox can be either two-state or three-state. Two-state ones store their states as 0 and 1, whereas the three-state ones use 2, 3, and 4. Here's the (reasonable) amateur attempt: unsigned GetNextCheckboxState(unsigned crnt) { assert(crnt >= 0 && crnt <= 4); /* Deal with two-state. */ if (crnt == 0) return 1; if (crnt == 1) return 0; /* Deal with three-state. */ if (crnt == 4) return 2; /* Or if the value's 2 or 3 */ return crnt + 1; } But this handles a lot of special cases, making it error-prone. Experienced developers learn to get rid of special cases, and try to find the underlying general case. For the above problem, here are a few ways of solving it. Wraparound as the only special cases: if (crnt == 1) return 0; if (crnt == 4) return 2; return crnt + 1; Data-driven, use a static array storing the next values: static unsigned nextVals = { 1, 0, 3, 4, 2 }; return nextVals[crnt]; This last one is the best: no special cases and it's logic simple. All it does is look up an array mapping a value onto the one that follows it. Buy some good books. Code Complete and Writing Solid Code are excellent. So are Programming Pearls and The Pragmatic Programmer. These are books every developer should have. K. ~| 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:192524 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
RE: better way to code?
Calvin Depends, In most cases you can do any conditional logic before rendering your page but obviously there are exceptions such as when the result of the condition determines what html is being displayed (and not something else such as if the user should be redirected or a session variable should be updated etc.) Some frameworks allow you to determine the portions of a page being rendered before the page is assembled allowing you to decide what portions are shown before they are rendered. Just my 2pence Kola > -Original Message- > From: Calvin Ward [mailto:[EMAIL PROTECTED] > Sent: 31 January 2005 13:50 > To: CF-Talk > Subject: RE: better way to code? > > In light of this discussion, how about lots of cfif statements buried in > html...? > > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Sent: Monday, January 31, 2005 8:46 AM > To: CF-Talk > Subject: RE: better way to code? > > Johnny > > Just to clarify, are you referring to lots of if statements in code in > general or lots of if statements in a fusebox switch file? If you were > referring to the latter then I would agree and say that in fusebox - you > should not have the majority of your logic within the switch file..is that > what you meant? > > Kola > > -Original Message- > From: Michael T. Tangorre [mailto:[EMAIL PROTECTED] > Sent: 29 January 2005 03:42 > To: CF-Talk > Subject: RE: better way to code? > > > From: Johnny Le [mailto:[EMAIL PROTECTED] > > I shouldn't have given that specific example. My reason for > > bringing this whole issue up is that people say beginners' > > code has a lot of CFIF statements. I am using Fusebox now. > > So it elimates a lot of CFIF statement already, but I still > > feel that I have too many CFIF in my code. I am just looking > > for alternative, better, and more efficient methods to handle > > all of those conditional statements. > > Who says beginners code has a lot of cfif statements? Why are they bad if > they are needed. I have worked on a lot of applications where a good > number > of if statements were needed all over the place... why is this bad? How > does > fusebox eliminate the need for conditional logic? Are you using FB4? > FB4.1?... = Sometimes a > case/switch > structure is a better choice over cfif/cfelseif/cfelse/cfif; usually when > there would be more than one (1) cfelseif, otherwise they perform the > same. > > Mike > > > > > > > > ~| 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:192318 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: better way to code?
In light of this discussion, how about lots of cfif statements buried in html...? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, January 31, 2005 8:46 AM To: CF-Talk Subject: RE: better way to code? Johnny Just to clarify, are you referring to lots of if statements in code in general or lots of if statements in a fusebox switch file? If you were referring to the latter then I would agree and say that in fusebox - you should not have the majority of your logic within the switch file..is that what you meant? Kola -Original Message- From: Michael T. Tangorre [mailto:[EMAIL PROTECTED] Sent: 29 January 2005 03:42 To: CF-Talk Subject: RE: better way to code? > From: Johnny Le [mailto:[EMAIL PROTECTED] > I shouldn't have given that specific example. My reason for > bringing this whole issue up is that people say beginners' > code has a lot of CFIF statements. I am using Fusebox now. > So it elimates a lot of CFIF statement already, but I still > feel that I have too many CFIF in my code. I am just looking > for alternative, better, and more efficient methods to handle > all of those conditional statements. Who says beginners code has a lot of cfif statements? Why are they bad if they are needed. I have worked on a lot of applications where a good number of if statements were needed all over the place... why is this bad? How does fusebox eliminate the need for conditional logic? Are you using FB4? FB4.1?... = Sometimes a case/switch structure is a better choice over cfif/cfelseif/cfelse/cfif; usually when there would be more than one (1) cfelseif, otherwise they perform the same. Mike ~| 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:192314 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
RE: better way to code?
Johnny Just to clarify, are you referring to lots of if statements in code in general or lots of if statements in a fusebox switch file? If you were referring to the latter then I would agree and say that in fusebox - you should not have the majority of your logic within the switch file..is that what you meant? Kola -Original Message- From: Michael T. Tangorre [mailto:[EMAIL PROTECTED] Sent: 29 January 2005 03:42 To: CF-Talk Subject: RE: better way to code? > From: Johnny Le [mailto:[EMAIL PROTECTED] > I shouldn't have given that specific example. My reason for > bringing this whole issue up is that people say beginners' > code has a lot of CFIF statements. I am using Fusebox now. > So it elimates a lot of CFIF statement already, but I still > feel that I have too many CFIF in my code. I am just looking > for alternative, better, and more efficient methods to handle > all of those conditional statements. Who says beginners code has a lot of cfif statements? Why are they bad if they are needed. I have worked on a lot of applications where a good number of if statements were needed all over the place... why is this bad? How does fusebox eliminate the need for conditional logic? Are you using FB4? FB4.1?... = Sometimes a case/switch structure is a better choice over cfif/cfelseif/cfelse/cfif; usually when there would be more than one (1) cfelseif, otherwise they perform the same. Mike ~| 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:192313 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
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
Re: better way to code?
I think I do and nicely put joei think like puting this.a=namea snd this.b = nameb you have direct access to this.a to get the name instead of loopoing through a result and going if current value eq b output name. Am I following ya Joe? Adam H On Sat, 29 Jan 2005 13:43:52 -0500, Michael T. Tangorre <[EMAIL PROTECTED]> wrote: > > From: Joe Eugene [mailto:[EMAIL PROTECTED] > > This is true to a certain extent, most logical conditions can > > be related > > to a data structure without conditions (If conditions) and in most > > situation the data structure make the code/application extensible. > > Joe... I don't follow you here?? > > > ~| 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:192199 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
RE: better way to code?
> From: Joe Eugene [mailto:[EMAIL PROTECTED] > This is true to a certain extent, most logical conditions can > be related > to a data structure without conditions (If conditions) and in most > situation the data structure make the code/application extensible. Joe... I don't follow you here?? ~| 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:192195 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
RE: better way to code?
>bringing this whole issue up is that people say beginners' code >has a lot of CFIF statements This is true to a certain extent, most logical conditions can be related to a data structure without conditions (If conditions) and in most situation the data structure make the code/application extensible. Joe Eugene >-Original Message- >From: Johnny Le [mailto:[EMAIL PROTECTED] >Sent: Friday, January 28, 2005 9:19 PM >To: CF-Talk >Subject: Re: better way to code? > > >I shouldn't have given that specific example. My reason for >bringing this whole issue up is that people say beginners' code >has a lot of CFIF statements. I am using Fusebox now. So it >elimates a lot of CFIF statement already, but I still feel that I >have too many CFIF in my code. I am just looking for alternative, >better, and more efficient methods to handle all of those >conditional statements. > >Johnny > > >>I'd say that any application that allows file paths to come from the >>URL is wrong, no matter the code. Second, any application that allows >>mixed relative and absolute paths for the same file is asking for >>trouble. And third, make sure you check for a leading "/" as well, or >>you code will puke on *nix. >> >>Now as for the coding style, the former is definitely better, though >>the whole block should be in a CFTRY..CFCATCH. In the second example, >>you need a CFTRY around the second CFFILE, and having multiple nested >>CFTRY..CFCATCH blocks gets too nasty to quick. Chances are good that >>if that scenario arises, you'd be better off doing some abstraction >>with either includes, UDFs, or a CFC. But again, I think it's >>unlikely you would ever be in this scenario with a well designed >>application. >> >>Also, don't use CONTAINS as your operator, use mid(url.dir, 2, 1) and >>see if it's a colon. >> >>cheers, >>barneyb >> >>On Thu, 27 Jan 2005 23:43:25 -0400, Johnny Le <[EMAIL PROTECTED]> wrote: >>> > > ~| 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:192193 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
I think the place I see too many if statements is for some matchmatical figures. I can't honestly come up with one on a saturday morning/afternoon after a long night of wedding planning but I have seen code like if today is monday add 6 if today is tuesday add 5 ect... When they could have used add 8-DayOfweek(now()). Adam On Sat, 29 Jan 2005 09:45:58 -0500, Claude Schneegans <[EMAIL PROTECTED]> wrote: > >>lots of CFIFs > > If one mean CFIF used when something simpler could be used, then this is > true, but it is not particular to CFIF, one could say that any piece of > code that could be simpler and/or more efficient makes the code look > amateurish. > Too many CFSET could mean exactly the same thing if there is a better > way to do the same thing. > > -- > ___ > REUSE CODE! Use custom tags; > See http://www.contentbox.com/claude/customtags/tagstore.cfm > (Please send any spam to this address: [EMAIL PROTECTED]) > Thanks. > > ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192184 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
Re: better way to code?
>>lots of CFIFs If one mean CFIF used when something simpler could be used, then this is true, but it is not particular to CFIF, one could say that any piece of code that could be simpler and/or more efficient makes the code look amateurish. Too many CFSET could mean exactly the same thing if there is a better way to do the same thing. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| 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:192179 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
>>but I still feel that I have too many CFIF in my code. The quantity of IF statements has nothing to do with the quality of code. Replacing them with CASE just for the sake of reducing the number of IF is completely idle. As someone pointed out, IF... ELSEIF reevaluates a conditional expression every time, though a CASE construct will evaluate ONE expression ONE time and work on values of the result. Then evrything depends on the logic of the algorithm: If you have only one expression to evaluate, work wits CASEs, if you need to evaluate a new expression for every case, you have no other choice than IF/ELSEIF. Furthermore, never replace an IF/ELSE with a two CASE construct, it is completely useless. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192178 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
>>Who says beginners code has a lot of cfif statements? Probabily beginners ;-) -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| 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:192177 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
RE: better way to code?
> I shouldn't have given that specific example. My reason for > bringing this whole issue up is that people say beginners' > code has a lot of CFIF statements. I am using Fusebox now. > So it elimates a lot of CFIF statement already, but I still > feel that I have too many CFIF in my code. I am just looking > for alternative, better, and more efficient methods to handle > all of those conditional statements. You're making this more complicated than it needs to be. Everyone's code has lots of CFIF tags. If you have simple conditional questions, use CFIF/CFELSEIF/CFELSE. If you have an expression with many possible values, use CFCASE. If you want to throw an exception in some condition, use CFTRY/CFCATCH. But don't worry about which is "right", because it just doesn't make a significant difference. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~| 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:192171 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
RE: better way to code?
> From: Johnny Le [mailto:[EMAIL PROTECTED] > There is a discussion right now in CF-Jobs-Talk called > "Indian Code". It says "I mentioned to the client that the > code looked like it was done by a first month CF programmer. > You know the type, pound signs everywhere, lots of CFIFs, > etc. Didn't say the code sucked or anything, just that it > looked amaturish." That is a HUGE generalization. First off, if conditional logic is needed, use it; that is what it is there for. How can conditional logic be "amaturish"... what is your alternative... avoid conditional code? How does cfset relate to cfif/cfelseif/cfelse? You can't compare the two as they serve two different purposes. Compare cfif/cfelseif/cfelse with cfsitch/cfcase if you want, that would be more relevant. > I tend to agree with this statement. Why? > Somehow beginners tends to use more CFIFs than the experts. Wrong. I consider myself pretty damn good at CF and I use cfif when necessary. What is too much? What makes an expert! > Have you attend any of Hal Helm's or some of the experts' > presentations? Their code seems to have a lot less CFIFs and > more CFSET. I don't need to see Hal's code to know how to use cfif and cfset... although I don't mind as he is a great presenter! > They just seem to organize things better. Yes they do! Fusebox and Mach-II are hihgly organized and structured which is why they are so appealing to me and many others. > don't want to turn this into a big discussion here. If you > have some tricks or tips to help me code better, make > good/better code, I'll greatly appreciate it. It seems the issue does need to be discussed if you think "a lot" of cfif constitutes "amaturish" code. Mike ~| 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:192169 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
Here's a link to the thread from last February about the relative speed of the two constructs, including results of the test that I did. http://www.houseoffusion.com/cf_lists/messages.cfm/Threadid=30474&forumid=4 The results were pretty conclusive, even moreso than I remembered. The tests weren't comprehensive, and they weren't designed to be, rather I was looking for some quick and dirty comparisons, which I got. I'm sure you can find scenarios where CFSWITCH will be faster, but that's not the point. Like I said before, I wouldn't worry about it at all. The relative speeds are actually quite minute, so take readability of the code as the top priority. If you later find (via granular load testing) that the specific construct is a bottleneck, then try using the other method, but until then, there are a lot better places to try and optimize (query structure, indexing your DB properly, data caching, etc.). cheers, barneyb On Fri, 28 Jan 2005 20:46:23 -0500, dave <[EMAIL PROTECTED]> wrote: > the reason i said that was y'all reemed me about 6 months ago on that and > everyone went off about how much better cfcase & cfswitch were, so now its > not? > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 6 invites. ~| 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:192167 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
Re: better way to code?
There is a discussion right now in CF-Jobs-Talk called "Indian Code". It says "I mentioned to the client that the code looked like it was done by a first month CF programmer. You know the type, pound signs everywhere, lots of CFIFs, etc. Didn't say the code sucked or anything, just that it looked amaturish." I tend to agree with this statement. Somehow beginners tends to use more CFIFs than the experts. Have you attend any of Hal Helm's or some of the experts' presentations? Their code seems to have a lot less CFIFs and more CFSET. They just seem to organize things better. I don't want to turn this into a big discussion here. If you have some tricks or tips to help me code better, make good/better code, I'll greatly appreciate it. Johnny >> From: Johnny Le [mailto:[EMAIL PROTECTED] >> I shouldn't have given that specific example. My reason for >> bringing this whole issue up is that people say beginners' >> code has a lot of CFIF statements. I am using Fusebox now. >> So it elimates a lot of CFIF statement already, but I still >> feel that I have too many CFIF in my code. I am just looking >> for alternative, better, and more efficient methods to handle >> all of those conditional statements. > >Who says beginners code has a lot of cfif statements? Why are they bad if >they are needed. I have worked on a lot of applications where a good number >of if statements were needed all over the place... why is this bad? How does >fusebox eliminate the need for conditional logic? Are you using FB4? >FB4.1?... = Sometimes a case/switch >structure is a better choice over cfif/cfelseif/cfelse/cfif; usually when >there would be more than one (1) cfelseif, otherwise they perform the same. > >Mike ~| 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:192166 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
RE: better way to code?
> From: Johnny Le [mailto:[EMAIL PROTECTED] > I shouldn't have given that specific example. My reason for > bringing this whole issue up is that people say beginners' > code has a lot of CFIF statements. I am using Fusebox now. > So it elimates a lot of CFIF statement already, but I still > feel that I have too many CFIF in my code. I am just looking > for alternative, better, and more efficient methods to handle > all of those conditional statements. Who says beginners code has a lot of cfif statements? Why are they bad if they are needed. I have worked on a lot of applications where a good number of if statements were needed all over the place... why is this bad? How does fusebox eliminate the need for conditional logic? Are you using FB4? FB4.1?... = Sometimes a case/switch structure is a better choice over cfif/cfelseif/cfelse/cfif; usually when there would be more than one (1) cfelseif, otherwise they perform the same. Mike ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192160 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
Re: better way to code?
I shouldn't have given that specific example. My reason for bringing this whole issue up is that people say beginners' code has a lot of CFIF statements. I am using Fusebox now. So it elimates a lot of CFIF statement already, but I still feel that I have too many CFIF in my code. I am just looking for alternative, better, and more efficient methods to handle all of those conditional statements. Johnny >I'd say that any application that allows file paths to come from the >URL is wrong, no matter the code. Second, any application that allows >mixed relative and absolute paths for the same file is asking for >trouble. And third, make sure you check for a leading "/" as well, or >you code will puke on *nix. > >Now as for the coding style, the former is definitely better, though >the whole block should be in a CFTRY..CFCATCH. In the second example, >you need a CFTRY around the second CFFILE, and having multiple nested >CFTRY..CFCATCH blocks gets too nasty to quick. Chances are good that >if that scenario arises, you'd be better off doing some abstraction >with either includes, UDFs, or a CFC. But again, I think it's >unlikely you would ever be in this scenario with a well designed >application. > >Also, don't use CONTAINS as your operator, use mid(url.dir, 2, 1) and >see if it's a colon. > >cheers, >barneyb > >On Thu, 27 Jan 2005 23:43:25 -0400, Johnny Le <[EMAIL PROTECTED]> wrote: >> ~| 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:192156 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
the reason i said that was y'all reemed me about 6 months ago on that and everyone went off about how much better cfcase & cfswitch were, so now its not? From: Barney Boisvert <[EMAIL PROTECTED]> Sent: Friday, January 28, 2005 8:39 PM To: CF-Talk Subject: Re: better way to code? Actually, I did some reasonably comprehensive tests on CFMX 6.1 sometime last year, and found that this was NOT the case with CFMX's implementation of CFML. Using CFSWITCH was noticably slower. I don't remember the specifics for sure, but around 30% slower seems familiar for some reason. Note that for a single operation (one iteration of my test loop) the execution time was zero or one milliseconds almost every time, so for a single execution pass, the difference is unmeasurable. At the very least, you are guarenteed that CFSWITCH cannot be compiled into a Java switch statement, because the Java variety only allows integer values, and CFML lets you have anything. So it's safe to assume that CFSWITCH ends up as a bunch of if..else if..else statements in the compiled Java bytecode. It seem that the CFML-to-Java translation is more efficient for CFIF than for CFSWITCH, hence the speed difference. I'm pretty sure this result is different than CF5's behaviour. It's also quite possible that BlueDragon, and/or Blackstone will have CFSWITCH executing faster than CFIF, but I don't know anyone who has tested. However, the speed differences are pretty meaninless. Readable code should be the determining factor for which you select, because the long-terms savings from readable code will be way more than the handful of microseconds you might save. cheers, barneyb On Fri, 28 Jan 2005 19:36:24 -0500, Claude Schneegans wrote: > >>It's good to keep in mind that CFSWITCH/CFCASE tests for multiple > values of the same expression, CFIF/CFELSEIF tests for multiple conditions. > > Abolutely, this is why CFCASE may be more efficient than CFIF/CFELSEIF > if the expression is the same. > But a CFIF/CFELSE also evaluates only one expression and is more logical > to use than a CFCASE with only two cases. > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 6 invites. ~| 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:192149 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
Re: better way to code?
Actually, I did some reasonably comprehensive tests on CFMX 6.1 sometime last year, and found that this was NOT the case with CFMX's implementation of CFML. Using CFSWITCH was noticably slower. I don't remember the specifics for sure, but around 30% slower seems familiar for some reason. Note that for a single operation (one iteration of my test loop) the execution time was zero or one milliseconds almost every time, so for a single execution pass, the difference is unmeasurable. At the very least, you are guarenteed that CFSWITCH cannot be compiled into a Java switch statement, because the Java variety only allows integer values, and CFML lets you have anything. So it's safe to assume that CFSWITCH ends up as a bunch of if..else if..else statements in the compiled Java bytecode. It seem that the CFML-to-Java translation is more efficient for CFIF than for CFSWITCH, hence the speed difference. I'm pretty sure this result is different than CF5's behaviour. It's also quite possible that BlueDragon, and/or Blackstone will have CFSWITCH executing faster than CFIF, but I don't know anyone who has tested. However, the speed differences are pretty meaninless. Readable code should be the determining factor for which you select, because the long-terms savings from readable code will be way more than the handful of microseconds you might save. cheers, barneyb On Fri, 28 Jan 2005 19:36:24 -0500, Claude Schneegans <[EMAIL PROTECTED]> wrote: > >>It's good to keep in mind that CFSWITCH/CFCASE tests for multiple > values of the same expression, CFIF/CFELSEIF tests for multiple conditions. > > Abolutely, this is why CFCASE may be more efficient than CFIF/CFELSEIF > if the expression is the same. > But a CFIF/CFELSE also evaluates only one expression and is more logical > to use than a CFCASE with only two cases. > -- Barney Boisvert [EMAIL PROTECTED] 360.319.6145 http://www.barneyb.com/ Got Gmail? I have 6 invites. ~| 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:192146 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
>>It's good to keep in mind that CFSWITCH/CFCASE tests for multiple values of the same expression, CFIF/CFELSEIF tests for multiple conditions. Abolutely, this is why CFCASE may be more efficient than CFIF/CFELSEIF if the expression is the same. But a CFIF/CFELSE also evaluates only one expression and is more logical to use than a CFCASE with only two cases. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192141 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
>More correct, not really. CFCASE, as any case construct in any language, >is not any better than a simple IF ... ELSE >IMHO, CASE constructs can be better for three cases or more. It's good to keep in mind that CFSWITCH/CFCASE tests for multiple values of the same expression, CFIF/CFELSEIF tests for multiple conditions. Will ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192133 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
On of java's pitfalls is file access, when compared to things like PERL, so anything you can do to cut down on file acessing the better so I would tend to say the first code with the IF would be better. Adam H On Fri, 28 Jan 2005 10:43:07 -0500, Claude Schneegans <[EMAIL PROTECTED]> 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! ;-) > > -- > ___ > REUSE CODE! Use custom tags; > See http://www.contentbox.com/claude/customtags/tagstore.cfm > (Please send any spam to this address: [EMAIL PROTECTED]) > Thanks. > > > ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192093 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
>>wouldnt using cfcase & cfswitch be more "correct"? More correct, not really. CFCASE, as any case construct in any language, is not any better than a simple IF ... ELSE IMHO, CASE constructs can be better for three cases or more. -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| 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:192091 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
Re: better way to code?
>>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! ;-) -- ___ REUSE CODE! Use custom tags; See http://www.contentbox.com/claude/customtags/tagstore.cfm (Please send any spam to this address: [EMAIL PROTECTED]) Thanks. ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192088 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
Re: better way to code?
I'd say that any application that allows file paths to come from the URL is wrong, no matter the code. Second, any application that allows mixed relative and absolute paths for the same file is asking for trouble. And third, make sure you check for a leading "/" as well, or you code will puke on *nix. Now as for the coding style, the former is definitely better, though the whole block should be in a CFTRY..CFCATCH. In the second example, you need a CFTRY around the second CFFILE, and having multiple nested CFTRY..CFCATCH blocks gets too nasty to quick. Chances are good that if that scenario arises, you'd be better off doing some abstraction with either includes, UDFs, or a CFC. But again, I think it's unlikely you would ever be in this scenario with a well designed application. Also, don't use CONTAINS as your operator, use mid(url.dir, 2, 1) and see if it's a colon. cheers, barneyb On Thu, 27 Jan 2005 23:43:25 -0400, Johnny Le <[EMAIL PROTECTED]> wrote: > Which method of programming do you consider is better? > > This one: > > > >output=""> > > > or this one: > > > > > output=""> > > > > I know that the first one is most people use, but the second one is more > interesting. It seems to use the power of CF more. So let me know what you > think. > > Johnny > > ~| 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:192061 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
re: better way to code?
wouldnt using cfcase & cfswitch be more "correct"? From: Johnny Le <[EMAIL PROTECTED]> Sent: Thursday, January 27, 2005 11:42 PM To: CF-Talk Subject: better way to code? Which method of programming do you consider is better? This one: or this one: I know that the first one is most people use, but the second one is more interesting. It seems to use the power of CF more. So let me know what you think. Johnny ~| 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:192056 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
RE: better way to code?
First one, second one should throw an error. And I would make it But then again its pretty dangerous allowing the path to come from the url if this website has public access. -- Taco Fleur Senior Web Systems Engineer http://www.webassociates.com -Original Message- From: Johnny Le [mailto:[EMAIL PROTECTED] Sent: Friday, 28 January 2005 1:43 PM To: CF-Talk Subject: better way to code? Which method of programming do you consider is better? This one: or this one: I know that the first one is most people use, but the second one is more interesting. It seems to use the power of CF more. So let me know what you think. Johnny ~| Discover CFTicket - The leading ColdFusion Help Desk and Trouble Ticket application http://www.houseoffusion.com/banners/view.cfm?bannerid=48 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192055 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=11502.10531.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54
better way to code?
Which method of programming do you consider is better? This one: or this one: I know that the first one is most people use, but the second one is more interesting. It seems to use the power of CF more. So let me know what you think. Johnny ~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192053 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
RE: Dynamically Getting Current Directory (Is There A Better Way To Code This?)
yeah. how bout i read your message first. nevermind. -Original Message- From: Ryan Emerle Sent: Tuesday, March 25, 2003 5:00 PM To: CF-Talk Subject: RE: Dynamically Getting Current Directory (Is There A Better Way To Code This?) expandPath('.')? -R -Original Message- From: Mike Alberts [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 25, 2003 4:57 PM To: CF-Talk Subject: Dynamically Getting Current Directory (Is There A Better Way To Code This?) Hello all, ColdFusion 5. I have this code in my index.cfm files in directories throughout my sites that sets the value of a variable to the name of the directory that the file is in (just the name with no slashes and backslashes, etc) cfset Request.ThisDirectory = ListLast(Replace(GetDirectoryFromPath(GetCurrentTemplatePath()),"/","\","all"),'\') This code works fine and lets me use it on both Windows and Linux boxes without changing it. But my question is, is there a better way to do it (that works on both platforms)? Case and special characters are not an issue as I always name my directories all lower case and no special characters. Thanks for any input. Mike ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 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 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
RE: Dynamically Getting Current Directory (Is There A Better Way To Code This?)
expandPath('.')? -R -Original Message- From: Mike Alberts [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 25, 2003 4:57 PM To: CF-Talk Subject: Dynamically Getting Current Directory (Is There A Better Way To Code This?) Hello all, ColdFusion 5. I have this code in my index.cfm files in directories throughout my sites that sets the value of a variable to the name of the directory that the file is in (just the name with no slashes and backslashes, etc) cfset Request.ThisDirectory = ListLast(Replace(GetDirectoryFromPath(GetCurrentTemplatePath()),"/","\","all"),'\') This code works fine and lets me use it on both Windows and Linux boxes without changing it. But my question is, is there a better way to do it (that works on both platforms)? Case and special characters are not an issue as I always name my directories all lower case and no special characters. Thanks for any input. Mike ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 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 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Dynamically Getting Current Directory (Is There A Better Way To Code This?)
Hello all, ColdFusion 5. I have this code in my index.cfm files in directories throughout my sites that sets the value of a variable to the name of the directory that the file is in (just the name with no slashes and backslashes, etc) cfset Request.ThisDirectory = ListLast(Replace(GetDirectoryFromPath(GetCurrentTemplatePath()),"/","\","all"),'\') This code works fine and lets me use it on both Windows and Linux boxes without changing it. But my question is, is there a better way to do it (that works on both platforms)? Case and special characters are not an issue as I always name my directories all lower case and no special characters. Thanks for any input. Mike ~| Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4 Subscription: http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4 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 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4