Recently Allaire released its newest version of ColdFusion, their powerful database integration tool. Part of the 4.0 release includes an addition to the Allaire lineup - the Enterprise version. This release hit the public later than planned, but was worth the wait. As I've been involved in this release since its alpha builds, I can attest to the fact that the development team took their time and listened to their control group of testers.
This article will give an overview of some of the improvements that 4.0 gives the developer without getting bogged down in technical jargon. As lead developer at Motorola for an application that's being used nationwide - soon to be worldwide - I'm interested in things that make my code cleaner, faster and more powerful. The following text assumes you need the same for your applications, and those are the enhancements that will be discussed.
Before diving into these enhancements, I need to point out the major difference between the Professional and Enterprise versions. While both can be considered safe for mission-critical systems, the Enterprise version takes it to the extreme. Allaire struck an apparent agreement with a company called Bright Tiger and their product, Cluster Cats. Cluster Cats provides the user with the ability to load-balance between multiple servers, provide server fail-over support and monitor various services on the NT platform. With an upgrade to Bright Tiger's full product, you'd also get content replication. Even without the upgrade, with a little imagination you could provide your own content replication through the use of batch files and the AT command set and NT's scheduler.
Don't assume that the Enterprise version is the only product in Allaire's lineup that can be considered mission critical. With the enhancements that were made to the product, I have had great reliability with the Professional version on Microsoft's IIS 4.0 platform. The use of Enterprise may eventually be forced upon me as the application I'm working on moves to a worldwide audience, as traffic is increased and as load balancing is required. A few of the enhancements that benefit both speed and reliability are obvious when looking at the ColdFusion Administrator for the first time.
The Administrator seems much more complex than the previous version...and it is. This is not because someone forgot about the end user, it's simply a statement that this product now packs all of the security, enhancements and flexibility required of today's database-centric applications. One of the first things you'll notice is the option for unresponsive requests. If you have set a time-out value for requests and those requests start timing out, the service is stopped and restarted. This singular feature is a powerful enhancement in itself. As a previous owner of a small ISP, I often had to restart services because things were locked up. This one feature, along with IIS 4's ability for process isolation, saved an awful lot of headaches and phone calls.
The features continue with a new one called the trusted cache. On first look, it impressed me as a feature that would never be used. On second look it was perfect for my needs. What a trusted cache does is to "trust" you, the administrator, that all the files in the template cache are the right ones and that no inspections for updates have to be made. Less work is faster! As I do all of my development on a test system and then upload the final code to our main server, I realized that this feature seemed perfect for an intranet that you have direct control over. This would cause a nightmare for an ISP, requiring the service to be stopped and restarted. The same workaround for the Access ODBC problem of using the NT scheduler to stop and restart the service (\cfusion\bin\cycle.bat) might ease this issue with ISPs.
There are other enhancements on what can be done with queries and such that enhance speed, but they'll be discussed with tag enhancements. Without getting bogged down in the aforementioned technical jargon, let me emphasize that Allaire has done a lot of work in the background to make their product line faster and more stable. They now boast "Enhanced Multithreaded Service" that scales well across multiple processors and "Improved Thread Pooling," which would probably be better discussed in a white paper than here. The bottom line is, it's faster and more reliable.
In fact, there are so many new features in this release that it will be difficult, if not impossible to cover them all. The best place to start a discussion on a new product would be with installation concerns. Being an MCSE/MCT, I lean pretty heavily toward Microsoft products, so I'll discuss two issues regarding the installation of ColdFusion on the IIS 4.0 platform.
Often, depending on your upgrade path of ColdFusion and an Internet information server, you'll have multiple, redundant application mappings set, which has been known to cause problems. But the condition is easily remedied. The first step would be to open the Microsoft Management Console (MMC) (see Figure 1).
Right-click on the server name and go to Properties (see Figure 2). Click on Edit with the WWW Service highlighted (default). Click on the Home Directory tab and then the Configuration button. This will bring up the Application Configuration interface. You should have only one mapping for .cfm files and one for .dbm files. In Figure 3 you'll notice that there are two of each; this is typical. Simply highlight one and click on Remove. Repeat for the other duplicate entry. It would be nice to do a multi-select, but it just won't work that way. Once the duplicates have been removed, double-click on each of the entries and ensure that the script engine Checkbox has been selected. Normally it is, but it's been known to cause a problem when it isn't.
The second installation issue is that of Crystal Reports. ColdFusion has direct support of Crystal Reports, and it's still in widespread use. When Crystal Reports 6 or 7 are installed onto the server, its default installation directory is \Seagate Crystal Reports. If the installation/upgrade is allowed to finish in this configuration, you'll quickly find out that Crystal Reports won't work. The problem is not with Crystal Reports or ColdFusion, but with IIS. Following the installation you'll see an entry in the Application Configuration (Figure 3) dialog for .rpt files. Double-clicking on it will bring up the Add/Edit Application Extension Mapping interface. If you then click OK, you'll see that IIS 4 doesn't understand the two spaces in the folder name and it will give you an error.
Correcting the misunderstood directory can be done in two ways. The first is to manually remove the spaces from the folder name with Windows Explorer and then to use REGEDIT (not REGEDT32) and do a search for "Seagate"; then change all of the entries in your registry to reflect the new folder name. Please keep in mind that making alterations to the systems registry is potentially devastating to a computer system. The second and preferred method is to simply uninstall Crystal Reports and reinstall into a directory without the double spaces. The service pack for IIS doesn't fix this problem...sorry.
The real joy of this upgrade is for the developer. While it's true that all of the enhancements already discussed have been geared toward the ColdFusion environment, there are plenty still left for the developer. The first enhancement I noticed right off was the debugging. It seems as if it's become more accurate. You'll notice that the error messages that usually directed your attention to the general area of the problem now seem to be more accurate. Better debugging means faster development.
Though this upgrade added many new tags and functions, a good portion of it didn't, enhancing current ones instead. Some of the changes were minor; others were more dramatic. The CFABORT tag is one of the simplest examples of this. Often my programming effort is geared toward data validation, making sure that what is being drawn out and going into the database is what is allowed and correct. This often requires complex server-side validation routines. If these routines fail, a message must be displayed to the user. The CFABORT tag now has an optional attribute, showerror. This option allows the programmer to put the error right into the tag instead of calling out a separate template, or to manually add the HTML code prior to the CFABORT tag. For example:
<CFIF Password NEQ PasswordConfirmation>
<CFABORT SHOWERROR="You have not entered the same password in both fields">
</CFIF>
This script would check the values of "Password" and "PasswordConfirmation"; failing that validation would result in the message predefined in the SHOWERROR attribute being displayed in the error page.
Error Occurred While Processing Request
Error Diagnostic Information
You have not entered the same password in both fields
In some cases you may want to dress up your error messages; I have adopted the above method as my standard. It is effective, and cleans up my code quite a bit.
The next tag enhancement that has taken a load off the server has to do with the CFQUERY tag. This tag has undergone a major transformation in my estimation. The attributes available to this tag are numerous:
BLOCKFACTOR, CACHEDAFTER, CACHEDWITHIN, DATASOURCE, DBNAME, DBSERVER, DBTYPE, DEBUG, MAXROWS, NAME,
PASSWORD, PROVIDER, PROVIDERDSN, TIMEOUT, USERNAME
Several of these options have always been around and I'm not going to explain every one. BLOCKFACTOR, CACHEDAFTER, DBSERVER, DBTYPE, PROVIDER and PROVIDERDSN all offer flexibility and power this tag never had before. The one option I have found very useful is CACHEDWITHIN.
Before I discuss what this new option offers, perhaps a little background is in order. Often in working with databases you'll find numerous "lookup" tables. A lookup table is one that associates a number with a larger group of information or perhaps its text counterpart. For example, a state lookup table would associate an int (number) with the standard abbreviation and full text name of the state. Everywhere else that state information is stored, the number goes in those tables, not the text.
Why would you do this? Simple. Searching on numbers is faster than searching by text. If your application provides the user with the ability to search through thousands of records using the state as possible search criteria, those searches will be quicker if you search by numbers. This is a simple but effective speed enhancement.
When I initially look at a database structure, one of the first things I do is to see where lookup tables are needed and how I can combine them. The application I'm working on now had no less than a dozen lookup tables that I was able to combine into a "common lookup" table. I then placed all this information into server variables with the following code:
<CFIF IsDefined("Server.GetCommonData") IS "No">
<CFQUERY DataSource="MyDS" Name="Server.GetCommonData">
SELECT * FROM tblCommonLookup ORDER BY LookupType
</CFQUERY>
</CFIF>
Throughout the remainder of the application I simply used the information that's stored in memory (server variables). I effectively eliminated thousands of queries per day with this one bit of code in my login action page. What does this have to do with CACHEDWITHIN ? Not a lot ... and everything.
Not all lookup information explained above will fit into a set model. In certain parts of an application, queries that never change are used. At these times I use this new option when a query is used time and time again without the data ever changing. When using CACHEDWITHIN, you'd normally use CREATETIMESPAN to set how long the query is to be cached. For example:
<CFQUERY datasource="MyDS" name="CacheThis"
Cachedwithin="#CREATETIMESPAN("0", "1", "0", "0")#">
SELECT ....
</cfquery>
The above code would cache the query for a period of one hour from the time the original query had taken place. You'll see this in your debugging code. You need to be careful with this option because if you're planning on adding new information to the affected table(s), it won't be reflected until the cached query times out and the information is drawn from the database again and not from memory.
Another major change is that of security. Security has been a major focus point of the entire 4.0 release. A major help to ISPs is the ability to control the CFFILE tag. Actually, CFFILE just follows the security guidelines you set up as an administrator. Even without setting up any security, CFFILE is not able to upload files or make any other file manipulations anywhere outside your Web server's directory structure. In version 3.x you could upload anywhere. I used to show this to students when I taught ColdFusion for Allaire just to demonstrate the potential hazards it posed. All of that has changed now.
During install you'll have the option of selecting the advanced security options; if you do, you'll be required to install Microsoft Active Directory Services Interface (ADSI) onto your server. To discuss the specifics on how to set up various security schemes would be an article in itself. If you're running an ISP or even an intranet with various applications, it would be worth your while to investigate this and the Studio integration with these various security measures.
Although I don't have the space to discuss every enhancement I've learned to use to empower myself as a programmer, this article would be incomplete without mentioning ColdFusion Studio. Studio 4.0 also received a major rework. Some of the new features that come to mind are the ability to assign Hot-Keys to code snippets, better integration into the server and security features, improved project management, faster page loading, much faster find and find/replace features and a host of others. I have been absolutely thrilled with Studio since its release. Although its query builder is a fantastic tool that handles a good portion of my SQL effort, it could use a bit of a boost. I have used Crystal Reports 6's visual builder to write better code for some very complicated queries. If you're using HomeSite instead of Studio, you're doing yourself an injustice.
The most profound part of this Studio release is the debugger. In Studio you can now set breakpoints in your code, check variables and values, look at the stack and more. Studio has now separated itself not only from other HTML editors, but from the basic definition of an HTML editor. It is now a programming tool for applications, not just pretty Web pages.
|