An interesting issue came up last week. A customer has a production server servicing a high load and running CFMX 6.1. We migrated his site from CF 4.5 "spaghetti" code sprinkled with custom tags to CFMX code with CFCs. The project was thorough and included load testing and a dev and staging environment. When we launched it seemed fine - better than expected actually. It ran fine for about 2 weeks, then suddenly developed a problem. It seems that under a very light (almost non-existent) load the server slowed to a crawl.Read More
Macromedia added "connectionless" DSN's in CF 5, then took them away again in CFMX. This much lamented feature was useful in certain instances. One of my favorites was for data export. For one of our e-commerce sites suppliers wanted a daily Access file for orders. We created an export process that copied an Access template to a new location (an Access db with the tables needed). Then we created an ODBC connection to it using the "connectionstring" attribute of CFQUERY and ran an insert routine to copy in the orders. The file was then zipped and automatically emailed to the supplier for drop shipment. In the words of Jimmy Neutron's Dad, "Now you gotta admit that's pretty neat!".
In CFMX however the connectionstring attribute is gone. This is because the system no longer interacts directly through ODBC. Instead it uses JDBC as the data access layer. That's a very good thing. We have had great results with speed and reliability through JDBC. It does put a crimp in our data export plan however. Fortunately there's a work-around. It's not perfect, but it works pretty well.Read More
I often pull in a full data set then use query of a query to pull subsets of data from it. The purpose is to minimize the number of hits to the database server (which is usually the cheif bottleneck of any application). This works pretty well, but today I stumbled on a tip that can really save some effort and reduce the sheer number of lines of code. It has to do with using aggregate functions to derive other values from the data. For example, if I have a large query that is being output in a row and I want totals at the bottom I usually run a query like this:Read More
It sounds like a dull topic. Right up there with "planning for retirement for 20 year olds". However, it certainly is important to understand some of the nuances of arrays and structures because how you use them (and your choices on which one to use can greatly affect the future scalablility of your application.
I saw an excellent discussion recently on an email list. I owe this information on arrays to Pete Freitag and Joe Rinehart. The question posed was, is the "length" of the array strictly tied to the number of members in the array. The reason this is important is because arrays are widely used for reasons of speed. Since an array is a list of references (points) it usually ranks as the fastest way to "loop" through data. I say "usually" to cover my butt. I actually don't know of any faster way in any language - although I'm sure the excellent and knowledgable readers of this blog will happily point some out to me (ha). Anyway, consider this code...Read More
Locking among CF developers arouses the same sort of Ire as the Linux Vs. MS debate. There are CF developers who believe that locking is unnecessary in most cases and locking everything is an unnecessary waste of time and effort. There are others who believe that everything should be locked without regard to any examination of the data or its significance. Both camps have salient points and I do not fault either of them for their viewpoint. In our case we err on the side of caution. We lock every write for the session and application scope and we lock "most" reads of the session scope. That's our standard and I only mention it to get it out of the way. I do not intend write an apology on wether you should lock or not. Instead, I think we should examine how locking syntax varies and how it used appropriately (or inappropriately).Read More
(reprinted from a previous blog)
If you have ever worked on a community site, or a site with salesman profiles or profiles of individuals, you may have said to yourself, "Self, it sure would be nice if each of these folks could have their own website". Doing it would require you to make a unique host entry for each user or create separate folders for each user and of course, that's not really easily managed. Or is it? Perhaps there's another way. Actually IIS and Cold Fusion give you a way to accomplish this pretty easily. 2 ways in fact.Read More
For example, using MOD 100 (or whatever threshold makessense to you) and currrent row I could run a calculation that gives me the percent commplete of the output. let's say 13 percent at row 200. Then, I would write this: ( <script> movie.SetVariable(13,"13%"); </script >) .. the first item is the frame number I want the movie to go to and stop, the second variable is a label. I use <CFFLUSH> to send it to the html page where it is run "inline" immediately. The result is a nice looking status bar that climbs incrementally at the top of the report and lets the user know that data is being sent to the browser and to please be patient. This approach can be useful for things like data upload tools where user uploads a spreadsheet or database that is subsequently inserted into a table or appended to a file.
For source files click here.Read More