Articles by Coldfusion User Group Members
The following are articles written by different Coldfusion User Group members.
-
Uploading Files, Delivering Them to the Visitor
- The manager security model
- The manager
- The upload page
- Discussing <CFFILE>
- Discussing SQL Inserts and Updates
- Discussing CFX_AutoResize
- The visitor's view
- To pop-up or hyperlink
- Database-driven "active session management". This session management does not store the session structure, but rather it is used for active login and session timeout tracking. Each time the file is called, we check the LoginAudit table to see if the user has used the system within the last xx number of minutes. The va variable (for validate authentication), contains the users login ID, CFID, and CFTOKEN, stored encrypted and in a comma-delimited list. We also use this string strictly as URLEncodedFormat.
- Ability to return wddx-encoded recordsets, and wddx-encoded result information.
- Helps to secure the actual database server, as accessing the database occurs through the Cold Fusion web server. In typical scenario, you would have a firewall in place - with the web server outside of the firewall, and the database server inside the firewall - the firewall would be setup to allow ONLY the web server talk to the SQL server. And accessing only a limited set of data and business rules through the web server, will help secure data (and also providing a platform independent method to manage your applications and data!)
- Application.cfm is always processed. More important, it will check the access validation. Which means, certain files may require that the user be logged in and with a current session (for security reasons), and will check the LoginAudit table for this active session.
- The application file is then called to perform the necessary operation. First, we either process the valid authorization, depending if this is a private query.
- Then, the instruction (aka queries, or whatever) is processed. Any variables you are expecting, you may want to set defaults using cfparam, to avoid any null problems. This block of code is used for general queries, business logic, calculations, etc. Feel free to use cfincludes, or whatever else you'd like.
- Lastly, we will create the WDDX packet. The WDDX packet will either be a recordset that contains data, or result information (error messages get passed here).
- Pass parameters as form or url variables. This will allow multiple methods of processing files - such as requesting recordsets based on form entered data.
- Ability to pass a parameter to indicate whether a wddx/xml recordset is generated, or if a javascript array is to be created.
- Cold Fusion Application
I'm going to demonstrate a couple small Cold Fusion files that take advantage of this concept. The functionality will be similar to the VB application functionality, this will be to demonstrate the cross-platform front-end development capabilities. - Visual Basic Application
A couple small sample VB modules will be included, this will show you the concepts behind this design using a client/server application and having a web-server act as it's database. - HTML/Javascript Method
No sample methods currently given. However, when converting a Cold Fusion recordset into a javascript object (or WDDX into JavaScript), you can use javascript to create a recordset array - thus allowing you complete control using javascript! - Wirelesss device
Using the same business logic and data structure as your other application and some front-end code, you can create WAP-enabled applications.
One of the most frequent tasks I am called upon to perform is handling browser controlled file uploads that are ultimately delivered to the site visitor. I just finished writing a nice project manager for a client this weekend, which inspired the article you are reading now. I cannot share with you a blow by blow manual on how to handle each step, but I'm sure that the outline of how I handled things will give you great insights on writing your own. Let's break down the process into several trains of thought...
One of the most frequent tasks I am called upon to perform is handling browser controlled file uploads that are ultimately delivered to the site visitor. I just finished writing a nice project manager for a client this weekend, which inspired the article you are reading now. I cannot share with you a blow by blow manual on how to handle each step, but I'm sure that the outline of how I handled things will give you great insights on writing your own. If you have any specific questions, I would be happy to answer them by e-mail.
Let's break down the process into several trains of thought.
I won't go into great detail here, but let's touch upon a few methods. I use different security models for different needs. You should first assess your NEED for security, and balance it with convenience. Customers and visitors will not use your application even if it is the best coded app on the net. It has to be easy, but it still has to do the job. Weigh your options. You certainly have to protect the "manager" area of the website where administrative personnel will be uploading files to be available to the general public. Or maybe the public isn't even public! I have had great success using a combination of server variables, cookies, database user/pass authentication and... I extensively use file permissions on the server itself.
A relatively simple security model could involve a login page that expires the login cookie upon loading, and then prompts the user for a loginID or a login/password combination. After the page is posted to a processor, it is authenticated against comparable fields in the database. Login cookies are then set, with perhaps a single day expiration. You could then keep the add/edit/delete manager function pages in a subdirectory that has an application.cfm that verifies the existence of the cookies. No, it isn't Fort Knox level security, but it is relatively secure and usually quite adequate for most purposes.
THE MANAGER
We already discussed keeping the manager pages in a subdirectory with an
application.cfm that verifies proper existence of login cookies. This is
only one way of ensuring that the general public does not have access to
your manager area. My favorite way is to use file permissions. If you have
any questions on how to accomplish this on an NT box running IIS, I would be
happy to share.
The manager will simply be a collection of web pages that allow you to ADD, EDIT and DELETE records in your database. I highly recommend that you use drop-down menus whenever possible (preferably data driven and not typed) to ensure data integrity. Specific to our problem here, let us address the page that will be uploading the file we wish to share with the public.
THE UPLOAD PAGE In our example, it may be either an image or a document of some type. Since we need to manipulate some of the information while processing our form, I have found it best to use SQL INSERT statements than contorting myself to use the CFINSERT statement.
First, we need to address the Form from which the file is uploaded. This is much easier than you may fear, if you have never done this before. You simply need to include
ENCTYPE="multipart/form-data"
in your form tag, and the input looks like this:
<INPUT TYPE="file" NAME="docfilename" SIZE="26">
I have not had any difficulty using the ENCTYPE attribute in either <CFFORM> or <FORM>.
This will upload the file with your form and post it to the next page, where we will process all this information.
Now, there are many ways to identify the record you just updated. Some people prefer to calculate the last row, I have a funny method that uses a seed. I slip a #RandRange(100000,999999)# in a field called just that, "seed". This is inserted in the record along with the data and I simply search for it, keeping the last value found. Yes, I know it is silly but it has worked for me a long time, and I stick with it. :)
Let's take a look at the actual processing page, and how I take care of business. Some of the code is unimportant to you, but I am including the entire example in case it brings you any insight...
<!-- notes_add2.cfm -->
<!-- THIS INSERTS THE MANDATORY DATA USING SQL INSERT -->
<CFQUERY DATASOURCE="#theDSN#">
INSERT INTO projectnotes(noteTitle,noteDateAdded,seed)
VALUES ('#noteTitle#','#noteDateAdded#',#x#)
</CFQUERY>
<!-- THIS PAUSES FOR TWO SECONDS AS AN ADDED SAFETY MEASURE, PERHAPS IN CASE OF VERY HEAVY SERVER TRAFFIC -->
<CFX_SLEEP SLEEPTIME="1">
<!-- THIS PERFORMS A QUERY ON ALL PROJECT NOTE ITEMS BASED ON THE RANDOM SEED -->
<CFQUERY DATASOURCE="#theDSN#" NAME="check">
SELECT *
FROM projectnotes
WHERE seed = #x#
</CFQUERY>
<!-- THIS SAVES THE RECORD NUMBER IN A VARIABLE -->
<CFOUTPUT QUERY="check">
<CFSET DARECNO = noteid>
</CFOUTPUT>
<!-- USING VALUES IN MY APPLICATION.CFM, THIS SETS THE PATH TO SAVE THE FILE BASED ON RECORD NUMBER JUST RETRIEVED -->
<CFSET DAFILE = "#domainPath#\#mainDirectory#\#DARECNO#">
<!-- THIS ENSURES THAT THE ABOVE DIRECTORY IS CREATED AND VALID -->
<CFDIRECTORY ACTION="CREATE" DIRECTORY="#DAFILE#">
<!-- THIS VERIFIES THAT A DOCUMENT WAS PASSED BY THE FORM -->
<CFPARAM NAME="docfilename" DEFAULT=" ">
<CFIF TRIM(docfilename) IS NOT "">
<!-- THIS SAVES THE FILE ON THE SERVER -->
<CFFILE DESTINATION="#DAFILE#\"
ACTION="UPLOAD"
NAMECONFLICT="OVERWRITE"
FILEFIELD="docfilename">
<!-- THIS CHECKS TO SEE IF THE FILE WAS AN IMAGE -->
<CFIF #FILE.ClientFileExt# IS "jpg" OR #FILE.ClientFileExt# IS "jpeg"OR #FILE.ClientFileExt# IS "gif">
<!-- THIS ENSURES THAT THE TWO SUBDIRECTORIES ARE
CREATED and VALID -->
<CFDIRECTORY ACTION="CREATE" DIRECTORY="#DAFILE#\CORRECT\">
<CFDIRECTORY ACTION="CREATE" DIRECTORY="#DAFILE#\THUMB\">
<!-- THIS RESIZES and SAVES TWO MORE IMAGES -->
<CF_AUTORESIZE IMAGEPATH="#DAFILE#\CORRECT\"
FILEFIELD="docfilename" THUMBPATH="#DAFILE#\THUMB\"
THUMBSIZE="75"
PREFIX="thumb_"
MAXSIZE="350">
</CFIF>
<!-- THIS UPDATES THE gallery RECORD FOR THE FULL NON-RELATIVE FILENAME OF THE FILE JUST SAVED -->
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDocURL='#FILE.ServerFile#'
WHERE noteID = #DARECNO#
</CFQUERY>
<CFELSE>
<!-- SINCE THERE WAS NO FILE LOADED,
WE'LL JUST DO NOTHING -->
</CFIF>
<!-- WE HAVE TO UPDATE ALL OF THE FIELDS WHICH MAY OR MAY NOT EXIST
SINCE WE COULD NOT ACCOUNT FOR MAYBES EASILY IN THE SQL INSERT -->
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET projectRef = #projectref#
WHERE noteID = #DARECNO#
</CFQUERY>
<CFIF TRIM(noteDetail1title) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDetail1title = '#noteDetail1title#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteDetail2title) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDetail2title = '#noteDetail2title#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteDetail3title) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDetail3title = '#noteDetail3title#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteDetail4title) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDetail4title = '#noteDetail4title#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteDetail1) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDetail1 = '#noteDetail1#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteDetail2) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDetail2 = '#noteDetail2#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteDetail3) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDetail3 = '#noteDetail3#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteDetail4) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteDetail4 = '#noteDetail4#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteCaption) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteCaption = '#noteCaption#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<CFIF TRIM(noteMemo) IS NOT "">
<CFQUERY DATASOURCE="#theDSN#">
UPDATE projectnotes
SET noteMemo = '#noteMemo#'
WHERE noteID = #DARECNO#
</CFQUERY>
</CFIF>
<!-- NOW WE LET YOU KNOW IT WENT OKAY -->
<CFSET cacheBuster = #RandRange(100000,999999)#>
<CFLOCATION URL="notes_add3.cfm?cb=#cacheBuster#">
================== END OF FILE =====================
That's how I add the documents; if you are interested in the slight variations required for updates, I would be happy to discuss them with you.
Let's talk about the CFX_AutoResize that I used. It is a free tag downloadable from the Allaire Gallery. (So was CFX_SLeep) After saving the original picture in the root directory that I created using the record number, I created two more directories: correct and thumb. I used the CFX tag to resize the image and place a 350 pixel width copy in "correct" and a 75 pixel thumbnail in "thumb".
THE VISITOR'S VIEW (To pop-up or hyperlink)
When I display the final file to the site visitor, I will check the file extension using #Right()# to see if it is an image. If it is, I display the thumbnail. Clicking on the thumbnail pops a window up that displays the "correct" image. Clicking on the "correct" images reveals the original, no matter what size it is! Because using a number sign in the HREF="#" usually irritates the cold fusion server, I write a meaningless javascript function, place it in the head of my document, and then call it from the HREF like this:
<SCRIPT LANGUAGE = "JavaScript">
<!--
// by Advantage Services.Net, Inc.
function noClick() {
}
// -->
</SCRIPT>
<CFIF #Right(noteDocURL, 3)# IS "jpg" OR #Right(noteDocURL, 3)# IS "gif">
<A HREF="javascript:noClick();"
onMouseover="window.status='Click Here to Enlarge'; return true"
onMouseout="window.status=' '; return true"
onClick='offsitewindow=window.open("http://www.#domainName#/common/displayPh
oto.cfm?x=#noteID#&path=projects","#RandRange(100000,999999)#","width=540,he
ight=420,scrollbars=1,resizable=1");'>
<IMG SRC="http://www.#domainName#/projects/#noteID#/THUMB/thumb_#noteDocURL#"
BORDER="0"></A><BR>#noteDocURL#
<CFELSEIF #Right(noteDocURL, 3)# IS "pdf">
<A HREF="http://www.#domainName#/projects/#noteID#/#noteDocURL#">
<IMG SRC="http://www.#domainName#/common/pix/pdf.gif" BORDER="0" ALT="Adobe PDF
Document"></A><BR>#noteDocURL#
</CFIF>
Before I provide that link, I do a quick check on the filename (the #NoteDocURL# field in the above example) If the file is not detected as an image (not a "jpg" or "gif") then it provides a standard icon that links to the file. In the app I wrote this weekend, I actually made about 20 little icon.gif files (CFELSEIF) for various file extensions, and used those icons when appropriate. It was very charming. :)
==============================================
I hope that this article was helpful. If you have any specific questions, please feel free to send me some e-mail. I also encourage discussion on how to improve things, or how to apply the same thing in a different environment with adaptive changes. After all, we're all in this together - right? I look forward to seeing you in the forums at http://www.cfug-sfl.org
Michael E. Cummins
Deriving eConomy from eCommerce
At this stage in the evolution of the "e" economy the information superhighway is visibly taking shape and its more of an information super-river than an interstate. Like a river the digital economy has taken the path of least resistance, lurching toward the most proximate opportunities emerging from incremental changes in the technological and market landscape
At this stage in the evolution of the "e" economy the information superhighway is visibly taking shape and its more of an information super-river than an interstate. Like a river the digital economy has taken the path of least resistance, lurching toward the most proximate opportunities emerging from incremental changes in the technological and market landscape. The evolution of the current information infrastructure was not executed according to some master plan directly connecting individuals and markets in one brilliant stroke. The current networked environment evolved more from a Darwinian process of constant experimentation and change not unlike the evolution of the markets that the technology itself serves. Like a river, the progressive evolution of the networked economy pushes in many different directions some of which create entire new companies, technologies and industries. The direction of a river is largely dependent on the contours of the landscape and the volume of water in transit. The landscape and water are analogous to market opportunity and technology. As new technologies emerge the super-river forces itself into new markets with inviting landscapes. Like a river the course of evolution is marginally predictable and vested with inherent uncertainties.
The trail of failed e-business projects and companies is testimony to the volatile and uncertain nature of the technology and market. Even the popular press is now focused on the growing body count of e-businesses with defective business models or ineffective execution. Many initiatives that are focused on productivity enhancements end up creating more costs than they eliminate. Executives evaluating e-business initiatives must make crucial assumptions about their markets and navigate through a universe of products and services to support the project. Any misstep in building market assumptions and project plans will compromise the viability of the initiative. Managing market and project risk is central to reducing the probability that the new e-business initiative doesn't become a costly experiment.
Market risk embodies the challenges that are external to the organization. Market risks emerge from changes in the competitive, technological and/or consumer landscape. All e-business initiatives make some assumptions about consumer and competitive behavior but often fail to consider alternatives. Most typically managers assume consumers will behave as they have predicted and competitors will do what they usually do. Defective assumptions are a leading cause of e-business failure and are more common when the business model is dramatically different than a successful existing model. Not surprisingly, ventures that are launching new business models face a higher degree of market risk than an old-line business that is extending an existing business process.
Project risks are the challenges posed to the timely and economic execution of the project. Project risks commonly originate internally and can be influenced by the organization and/or its vendors. If project risk is properly managed the initiative should permit the organization to exploit the underlying market assumptions. The scope of an e-business project may be extremely complex with casts of users, analysts and implementers that must come together to define project requirements, technology, vendors and timeline. Each link in the project poses its own unique risks. Common project risks may include staff turnover, inadequate skill level, incomplete requirements, etc.
Many tools exist for project owners to mitigate the market and project risks they confront. At the strategic level financial and market analysis of project assumptions can approximate project viability. At a tactical level there are numerous methodologies and tools for managing complex projects. Return on investment analysis and project management tools are a prerequisite to achieve a successful implementation but are not a guarantee. Effective management of existing and emergent risks is a key to successfully navigating e-business opportunities. Each and every project has its own set of risks and rewards and defies a one-size-fits-all solution. There are however certain common denominators that, when applied can help implementers avoid the mistakes of others and meet project objectives economically.
Select a Technology Standard
The market for technology products is extremely diverse. There is no one technology that is right for the entire scope of users. The requirements of a project should however, align with the characteristics of the technology. High volume transaction intensive projects may call for security and scalability attributes that aren't needed for a non-transactional static web site for example. Certain characteristics of the selected technology will be key in the ability to maintain flexibility and help to mitigate market and project risks.
Technological standards are a critical factor in the deployment, maintenance and enhancement of any e-business initiative. If the software and hardware components you select adhere to an accepted industry standard you will have numerous advantages over products that are proprietary in nature. Typically the pool of available labor is greater for standards based products. The flexibility to integrate diverse components is enhanced by a common technology standard. Products based on technology standards offer customers greater flexibility and they typically have a lower cost of maintenance and enhancement. Vendors offering a proprietary product can lock customers into their platform through high switching costs and typically more expensive to alter and maintain. By selecting a common technology standard as the backbone of an e-business initiative managers can reduce the risk that they will be unable to react to market changes in an economical and timely way. Standards further reduce the project risks posed by staff turnover, training requirements, integration and vendor-lock.
Only Build What You Can't Buy
Most managers who have evaluated e-business projects are confronted with the option of building or buying the applications to address their needs. The option of building an application, either in-house or through a consulting firm has the advantage of being specifically designed to meet unique requirements and business processes. Although a custom project can meet a majority of customer needs, the project is usually lengthy and complex posing expanded project risk. Alternatively, buying a pre-built application has the advantage of being faster to market and more reliable. Most commercial applications have ostensibly been through a process of customer acceptance and evolved to a higher level of reliability than custom projects. This of course, may not be true if you are the vendor's first customer, but the majority of applications have had more usage and iterative change than the typical custom project. Some projects demand completely custom solutions due to the uniqueness of their business processes and/or model. Many business processes are, however, relatively similar and share common objects and tasks making the acquisition of a pre-built application that satisfies eighty percent of a customers requirements possible. Addressing the twenty percent balance of customer requirements can mean the difference between achieving plan goals or being an also-ran.
Achieving reliability, speed to market goals and one hundred percent of user requirements demands a third approach to the build-or-buy question. Customers should seek proven applications for which there is a toolset and infrastructure that permits the extension and modification of the application. This approach combines the quality and deploy-ability features of a production proven application with the ability to customize unique business processes and functions. These extendable, or living applications permit companies to iterate on the application creating features and functions beyond what other users of the same application can offer.
Selecting a pre-built application that has a track record of reliability and performance and matches most project requirements can greatly reduce project risks associated with custom development. Additionally, market risks associated with time-to-market are reduced. Selecting an application that is designed to be extended and modified can further reduce market risk by cutting the time necessary to iterate and react to market changes. The ideal product should include a toolset that creates a common work template for business analysts, programmers and designers to further reduce project risk. The application approach combines the advantages of building and buying your e-business project.
Plan For Change
The common reframe about e-business projects is the only thing certain is change. The ability to iterate on projects and extend them to take advantage of new opportunities or counter competitive threats is mandatory. Whether market or technology driven, change is inevitable and project plans should accommodate anticipated and unanticipated events. By selecting products that conform to standards and assume an application approach managers can greatly reduce market and project risks. A blueprint that approximates future requirements and development options will ensure that the impact of all current and future decisions are measured against their impact on future capabilities.
The ideal solution should be designed for change with an underlying infrastructure based on an object architecture. The solution should be characterized by a compartmentalized design with components built for reusability. Modularity in design will greatly enhance adaptability and extension. An infrastructure that is designed for change will reduce both market and project risks.
Get eConomy
Customers can benefit from some of the best and most costly implementations in production today by acquiring the product-ized version offered by original vendors. By acquiring the application customers avoid the development overhead and benefit from the beta customers who acted as the crash-test-dummies for reliability, safety and security. With the additional benefit of compressed deployment times customers can better address market and project risks inherent in lengthy development cycles.
Products that conform to industry standards further expand project flexibility. Standards based platforms can take advantage of best-of-breed products through ease of integration and help to limit lock-in arrangements with proprietary products vendors. The internet itself was largely made possible through the adoption of standards, it is imperative that any technology selection be made with an eye to future compatibility, expandability and economy of maintenance.
The ability to customize and extend the foundation application is a key requirement in the current and future e-business environment. Planning for the iteration and the extension of each phase of an implementation is necessary to fine-tune any project. Any application that is selected should be built with this key characteristic in mind. A toolset and architecture that supports repetitive change and experimentation will reduce current and future market and project risks.
Deriving economy from e-commerce means building on the best-of-breed by adapting those applications to your business processes and not compromising preferred processes for those of the pre-built application. Optimal solutions should encapsulate a standards based run-time infrastructure, applications and tools. In this way customers can mitigate many of the inherent risks of embarking on a e-business initiative.
Newbie to Newbie: The Trials and Tribulations of Cold Fusion Tenderfoot
It is pretty standard fare in "Designer-Ville" these days: some Johnny-Came-Late-to-the-Web bursts through the door, ringing his hands because he truly believe his Online challenged status has cost him the deal that would have enabled him to retire by the end of year and live out his days in languid repose on the beaches of Antigua
It is pretty standard fare in "Designer-Ville" these days: some Johnny-Came-Late-to-the-Web bursts through the door, ringing his hands because he truly believe his Online challenged status has cost him the deal that would have enabled him to retire by the end of year and live out his days in languid repose on the beaches of Antigua with nothing more to do than watch his assets multiply like germinating spores in pollen season. Translation, some AOL using neophyte, who has yet to successfully download and install a Flash plug-in for his browser, wants to be the next robber baron of cyber space. Since he has already enlisted a realtor to scout for the availability of the lot just over the wishing well from Jeff Bezos's Casa de Dollara, he wants his site launched like, yesterday. Predictably, he has no domain name, no hosting plan, no content, an outdated logo complete with a decidedly web-unfriendly gradient background and a huge catalog of wares he is sure the world is hungry for.
Three domain names, four logos, five interfaces and six months later, Mr. I-Want-it-Now had finally signed off on the look and feel of the site. That was the good news. The bad news is that until the site is launched, we do not get the rest of our fee. Even worse, the time delay had found our small firm "between programmers." A front end without a backend to make it function is not going to make anyone any money. The next morning, I discovered a shiny, glossy sinister looking box of software on my desk: Cold Fusion by Allaire. I have heard of Cold Fusion...that's like, programming...right?
My life suddenly turned into "Nightmare on Cyber Street" with me in the starring role. I felt like the like sleeping frat boy, awoken from a sound slumber for the sole purpose of being designated driver for his fellow Sigma Chi's and enlisted to pilot the Jeep Laredo for a post-midnight run to International House of Pancakes. But wait a cotton picking minute - I hate to drive so programming is definitely not on my route. I mean I have written ads to hire programmers and even those seemed like cryptic ramblings of Bart Simpson with his lips caught in a garden hose: XML, VMR, SQL, WDDX, PHP, DB4. Don't programmers ever watch TV? I am sure Vanna White would give them a vowel if they asked real nice and then just maybe, those terms would make sense to rest of us.
The fact is, the tables had all turned and suddenly I was the neophyte in the room. "Well, if you don't think you'll be able to figure it out..." were the only words that had to land on my ears. One thing about business partners - they sure know how to push your buttons. Before they had even finished their sentences, I had found a database tutorial on the web and was ridding the Cold Fusion carton of it's cellophane. I quickly learned the acronym for Structured Query Language was SEEK-WOOL as opposed to "SQUEAL" as I had always thought - although as I attempted my first data retrieval exercise, I began to think the latter was more appropriate. I grabbed the Cold Fusion manual, popped the disc in the drive and let the installation wizard perform its magic when a little line in the software guide let me know I was already doomed. "You must have a web server installed and running prior on your machine prior to installation of the CF Personal Application...." Now wasn't that a fine time for that news flash. As I searched for my Windows98 disk, I told everyone within earshot to fasten their seatbelts...it was going to be a bumpy byte!
If you have "been there, done that" you already know what happens next. If this is still in your future, since after all, this is the Newbie Column, time to pay attention as believe me, this will save you from hours of grief, frustration and a headache the size of which deserves its own area code. The Windows98 disc has a Personal Web Server right there in the "Add-ons" folder and if that sounds too easy...it is. Yes, it is a bona fide PWS but if you want your new CF Application Server actually function, reach into your pocket and find another quarter for the jukebox, because you need to make a new selection.
No, it does not mean you need Windows 2000 or even NT much as that might make sense. In order for PWS and CF to reside on your machine in harmony and actually perform the requisite functions of sharing, passing, retrieving and sending the results back to you, the PWS that was developed for Windows95 comes bundled with an NT option pack to proves to be just what the doctor ordered. Now in theory, that doesn't make sense but trust me, it works. Here's where you can get it: http://www.microsoft.com/windows/ie/pws/default.htm but not so fast: our little party is just beginning.
Getting the setup file is deceptively quick. Once you click on it, it turns out to be merely a wizard that reconnects you to the Microsoft server where the real 21631 KB file makes it way into your hard drive. Even with my DSL connection the download seemed to last longer than the tenure of a new comedy series on WB network so let the download take its course and put the time to good use. Make sure you have Microsoft Access installed on your machine (it comes with MS Office). In addition, there are many beginner SQL tutorials on the web: do them. If the syntax of your SQL statement is wrong, your CF application will just roll over and play dead. I will give you a major hint: in SQL, case doesn't matter but punctuation does. Comma, hyphens and quotations act as operators in your queries and there is no margin for interpretation here.
All righty then, so finally your PWS download is complete. The installation is running along smoothly until that last little blue box is about to fill in the "installation progress window" and wham - you hit an iceberg called "Unknown Error Occurred" and the USS Microsoft goes glub, glub, glub. You are then treated to a duo of alert boxes with the scary statements like "error making changes to your system registry and Transaction Server Core Component failure." The process completes and gives you a little message stating installation is complete but your PWS may not be fully functional. This, boys and girls, is not a drill. Yes, you get a little icon in your sys tray that says your PWS is running and yes, you can format your own little home page from the template wizard and yes, you can even local publish .html files and view them right in your browser but no, it will not pass that all important code between your CF tags to the CF server and therefore, Will Robinson, it does not compute. Do not do the following (okay, you can correctly read between the lines and gather I did all of the following exercises in futility): try running the installation program again; uninstall then reinstall, start from scratch and get the download file from the Microsoft site and resume the entire process from square one, install CF Studio or Sever, or any mixing and matching of the preceding. Buried deep within the knowledge base of our friends at Gates and Company is an admission that this little gem may not install properly.
Quell Surprise. This tidbit, incidentally is not attached to any support documents under PWS, downloads, patches, options or troubleshooting. However, in the "Alice In Wonderland" surrealism of needing a Windows95 program with an NT option pack on your Windows98 system in the year 2000, that should come as a shock to no one. It seems the mtssetup.exe supplied with the PWS is a little buggy & needs to be replaced. Go to http://support.microsoft.com/support/kb/articles/Q214/6/44.ASP to download the new and improved version. Simply get it, install it in the folder automatically created that holds your PWS setup files. Click yes to overwrite the existing mtssetup file, click on the setup icon again and Houston, we have a lift off.
Finally, you get to launch your CF Application server. It working like a dream and returns the query for those biology classes, letting you know your configuration is hunkey doory. Information is plentiful now, you can even preview Allaire's first lesson of their "Skill Building with Cold Fusion" under the training portion of their site that walks you through installation of both the CF Studio and Server. Feeling brave and empowered, you fire up the CF Studio and chomping at the bit, click on the database tab. But hey, it doesn't prompt you for a password like they promise in demo-it just says unable to communicate with local host. Holy déjà vu, Batman...I thought we had outgrown this stage. Remembering that CF is a powerful and robust application designed to execute dynamic and robust applications over the Internet, otherwise you would never want to learn it in the first place, therefore expecting it to work on your personal little network and a freebie web server is like a like taking your "big wheel" to Auto Center at Sears to get one of the pedals replaced. However our friends at Allaire have already done their homework and have a solution that was an easy as one email to installation support. Go to the following and get the following file: http://www.allaire.com/Handlers/index.cfm?ID=14102&Method=Full. Extract it, and then use it to replace the cfrdsservice.exe in the /cfusion/bin directory, and then reboot your machine. Open CF Studio, and you will retrieving local files to your hearts content.
The common bond between all of these tales of woe are that they are not matters addressed in any FAQs, manuals or installation guides and frankly, they seem too stupid to even consider asking about them in a newsgroup. Until they are solved, however, you are stuck at ground zero. I hope I have helped you get up and running so we you can get down to the business at hand: designing and executing Cold Fusion applications. I am still green around the ears, but can proudly state I have designed applications that actually do what they are supposed to. And hence, the purpose for this column: everything you ever wanted to ask about Cold Fusion but were afraid to ask. I promise not to laugh, after all, seems like I was stymied by the same question you have just yesterday-in fact, it probably was yesterday. Each month here in Newbie to Newbie, we will explore some of the basic, initial and often puzzling stumbling blocks of the CF voyage in programming land. Question to ask? Tips to share? We would love to hear from you!
See you next month!
Introduction to the Fusebox Methodology
Many people ask what fusebox is, and when many first look at it, they may be confused or don't understand it's practicality. Hopefully that will change after reading this article.
The fusebox style of coding is simply that, it's a style. This method uses the closest thing possible to an object-oriented approach in the Cold Fusion code. I have coded many different CF-based applications, many in a spaghetti code, and many in a fusebox methodology
Many people ask what fusebox is, and when many first look at it, they may be confused or don't understand it's practicality. Hopefully that will change after reading article.
The fusebox style of coding is simply that, it's a style. This method uses the closest thing possible to an object-oriented approach in the Cold Fusion code. I have coded many different CF-based applications, many in a spaghetti code, and many in a fusebox methodology.
Fusebox promotes code readability, code reusability, improved efficiency in development teams, and easier code documentation. Again, the important thing with the fusebox style, is to do your coding in a format that's easily recognizable and understood by other developers.
To start with, there are several types of files used in the fusebox style.
Qry_filename.cfm - These are query files, they should contain only query related code. As example, qry_Account.cfm could query the account table and retrieve information for a particular account.
Dsp_account.cfm - Display files contain all of your display type content, including your dynamic Cold Fusion code for formatting your screen.
Act_action.cfm - Action files are used for logical processing - such as saving files, performing special validation, etc.
There are a few more suggested file types, but we'll start off with these.
The index.cfm file looks like a standard and default CF file. It contains an html header and footer. The first section we have is the CFSWITCH area. We use CFSWITCH because it is much faster and more efficient than using CFIF (and it's easier to read in my opinion). Basic on the URL ACTion variable, we will determine what display file to use. As you can see, if the url.act = "some_other_page", we will set ct_inc to "dsp_usermenu.cfm".
The index.cfm above is setup to display the header, left-frame (like a menu), the content area, and the footer.
Other things to note
You don't need an application.cfm file in every file - you can place it in the top of the index.cfm.
Using fusebox, reusing your various dsp and qry modules is easy, so take advantage of this (life will be easier).
In my opinion, the fusebox style should not be something you do according to someone else's "rules", but rather, take the concept and apply it in a way that makes sense to you (don't stray toooo far though). The real purpose of it is a) reusability and b) make it easier for you and other developers to understand the code!
For detailed information on the fusebox methodology, and a far more detailed and advanced description of it, be sure to visit www.fusebox.org.

Commerce Confusion
If electronic commerce market penetration was measured by media hype, one may think the internet bonanza was peaking. Many companies, large and small are pursuing eCommerce projects in an orgy of experimentation. These internet initiatives
If electronic commerce market penetration was measured by media hype, one may think the internet bonanza was peaking. Many companies, large and small are pursuing eCommerce projects in an orgy of experimentation. These internet initiatives have drawn enormous interest and attention, but as of yet, few have emerged as clear winners. Assuming that winning strategies are those that produce clear and tangible financial results (stock gains not included) the largest group of successful internet initiatives have been those that are focused on the improvement of business processes for brick-and-mortar companies. The success of Cisco, Dell, Michelin and many others in improving existing business processes and yielding measurable financial results stands in contrast to many emerging business models including e-tailing, exchanges and marketplaces. The use of the internet to improve existing business practices for the majority of small and mid-tier companies remains a largely unexploited and fertile market far from its peak.
Despite the seemingly obvious need for corporations of all sizes to migrate their business processes to the internet, many companies have been unable or unwilling to pursue online strategies. Different industries and markets are faced with unique and complex characteristics many of which may effect an eCommerce decision. Market demographics, customer preferences, current business practices, channel conflict, competitive landscape and many more factors contribute to the necessity and utility of an internet strategy. But for those corporations that recognize the need to deploy on the web, the hardest part can be where to start. Developers and integrators must be prepared to guide executives in a consultative process through the maze of strategic options and, if necessary, provide them with the information and tools to make informed decisions.
The bewildering array of strategy options, software vendors and integrators has created a misery of choice catching many executives in the headlights of the oncoming opportunity. Managers are now confronted with channel decisions ranging from the now ubiquitous business-to-consumer (B2C) and business-to-business (B2B) to the emerging business-to-exchange (B2E) and exchange-to-exchange (E2E) models. Scarce resources must be apportioned between the buy-side and sell-side initiatives. Each strategic choice is associated with its own inherent complexities in transaction types, workflow, content, product configuration, commerce platform and infrastructure. Executives and boards must further decide if it is more cost effective to rent, build or buy the hardware and/or software necessary to deploy their selected strategy, forcing the evaluation of countless hosting, application and commerce service proposals. The process of making these strategic decisions isn't aided by the claims of software vendors which have converged around the same insipid messaging and phraseology ("robust, scalable and extensible solution for 7x24 interactivity") making them all sound surprisingly similar.
Most businesses can discern the high-level strategic implications of eCommerce decisions but lack the empirical data upon which to make simple assumptions necessary in preferred metrics like return-on-investment (ROI). How many potential customers will visit my site? How many of those will buy? What services will they expect? How long will the average session be? How many pages will be served per visit? Will my site require advertising to build traffic? How often should my content be changed? Do I need to be integrated to an exchange or marketplace? What is the optimal server and technology configuration? Many companies also recognize that deployment of online initiatives without back-of-house system integration means scaling their system with bodies instead of machines further complicating the decision. Guidance can be gleaned from the likes of Forrester, Gartner and AMR, but for the most part this analysis only covers fortune 2500 companies and leaves the rest of the market to vendor claims and anecdotes. Inevitably all decisions regarding technology, hardware, software and services come down to the assumed return to the business. The assumed return to the business rides on the assumed traffic and transactions derived from the site and the assumed behavior of customers, partners and competitors. Many small and mid-tier businesses have postponed deployment decisions until the uncertainty in the balance between costs and benefits becomes clearer. This presents a significant opportunity to vendors who engage the customer throughout the eCommerce discovery process.
Top-tier developers and integrators, now more than ever, couple their client development activities with strategic and business process consulting engagements. These engagements are often mutually exclusive from the development project and serve the purpose of influencing the customer's decision and developing ironclad requirements for any ensuing initiative. Far from the relatively straight forward ROI calculations involved in a ERP, CRM, database or SFA decision, eCommerce opportunities must be measured with far more qualitative data. Mid and low-tier developers must now more than ever couple their services with upfront consulting engagements to solidify their position in an account and better adapt their products services and partners to a customers requirements.
Using CFSCRIPT
What is CFScript? Cfscript is a CF function that allows you to use JavaScript type code in your CF templates. Now I am sure you might be saying why would i use CFSCRIPT? I do not like Javascript, this seems like a step backwards. Well I would say there are pros and cons to using CFSCRIPT in an application. Some of the benefits of using CFSCRIPT is it is very easy to set variables. Lets compare:
What is CFScript? Cfscript is a CF function that allows you to use JavaScript type code in your CF templates.
Now I am sure you might be saying why would i use CFSCRIPT? I don't like Javascript, this seems like a step backwards. Well I would say there are pros and cons to using CFSCRIPT in an application. Some of the benefits of using CFSCRIPT is it is very easy to set variables. Lets compare:
{using CFSET}
<cfset myVar=len(trim(varXZ))>
Now that was very small and painless. Lets look using CFSCRIPT
{using CFSCRIPT}
<cfscript>
myvar=len(trim(varXZ));
</cfscript>
Looks like more code for just 1 variable? Then where does CFSCRIPT really shine...? Well using cfscript for a larger group of variables, as well as Cfscript (after being benchmarked) ran 10% faster then using CFSET. Lets look at another example:
<cfset a="Firstname"> <cfset b="Lastname"> <cfset d=len(trim(a & " " & b)> <cfset today=now()>
Now with CFSCRIPT
<cfscript>
a="FirstName";
b="Lastname";
d=len(trim(a & " " & b);
today=now();
</cfscript>
One of the best benefits of CFSCRIPT is the fact that using CF FUNCTIONS within a CFSET can be bulky and confusing sometimes, but using CFSCRIPT you can define them inside the <CFSCRIPT> tag just as it would seem to want to be positioned naturally.
With CFSCRIPT you can use it to make loops that are more like Javascript loops and VB loops rather than using <cfloop from="1" to="100" step="1">.
Does that mean you need to redo all your applications to stop using CFSET and use CFSCRIPT? No. But it does mean that in certain situations cfscript can save you a lot of coding/debugging time and speed up the processing of the page. One of the biggest keys with CFSCRIPT is always remember to end your lines with a semi-colon or (to quote the famous Adam Churvis) "The template will spit its skull out!" and it will not properly run.
The Style File
Fire and water, MTV and the Moral Majority, the Hatfield's and the McCoy's, Web designers and Programmers: what to these groups have in common? Nothing, except the fact they all hate each other with the veracity of a bi-polar schizophrenic on a collision course with a revolving door. As for fire and water, looks like nature has pretty much solved that one for us.
Fire and water, MTV and the Moral Majority, the Hatfield's and the McCoy's, Web designers and Programmers: what to these groups have in common? Nothing, except the fact they all hate each other with the veracity of a bi-polar schizophrenic on a collision course with a revolving door. As for fire and water, looks like nature has pretty much solved that one for us. The MTV debate: well we'll divert to the FCC and the Vatican. Now, since Sheriff Andy Taylor seems to have a handle on the feuding families of Mayberry, that leaves us with the battle of the vanguards of form Vs. the torchbearers of function to duke it out on the page here today. As a designer turned programmer, or at least one attempting to make that pilgrimage to the big boy chair, I may not have all of the answers, but I can certainly play referee. It is not that web designers don't understand you: it is that they do understand what you do that is the real source of the conflict.
The designer's domain is the front end. They reside on the long thin branches of a tree swaying tenuously in the winds of change primarily ushered in by the often taste-impaired patrons who keep company in business. The delicate matter of not adhering the color scheme of client's alma mater, suggesting that no matter how cute the logo that their grandchild designed is, it might not be the exact fodder for effective digital branding or that the complete streaming version of their radio commercials might a bit long to use as background music for the splash page are not exaggerations of the woes they face, they are the reality of them. The other reality is that designers, account representatives and the clients themselves have all share the fairy tale belief that once the front end is in place, a simple plunk of code and abracadabra, the site is finished and open for business. There simply is no concept that not until then can you attack your side of the equation and produce anything resembling a finished application that looks like it actually belongs in the site much less functions. When a designer pops their head in your office on their out the door with a by-the-way announcement that there will be a whole new interface and navigation bar in the morning, it truly does not register that little revelation can instantly render weeks of writing, tweaking and debugging into now useless lines of code you would now like to shred as use as kindling for their funeral pyre.
Designers simply don't know the hurdles you faced in the debate with the web-master over client vs. server validation and are oblivious to the fact that the 23 year old pencil faced vapid excuse of sysadmin practically required you to type your DNA just to get the permissions you need to properly configure the server after he made a royal kluge of it. Add in little goodies like the ever present reality that the clients' database is not nearly as scalable as you were led to believe and there you have it: either the plot line for the next John Grisham novel or a day in the life of a Cold Fusion developer. The old adage if you can't beat em, join em might not apply here 100%, but developing a little design savvy can certainly help bridge the gap. Who knows, you might just be able to teach those artsy-farsty types something that they feel is actually important and prove that programmers aren't so dumb after all.
SIZE MATTERS: The resolution evolution
Whether you work on the front or the back end, there is a nagging question with vexing implications for anyone who works on the web: low-resolution monitors are quickly being replaced by new, higher resolution models. As the higher resolutions equate to more screen real estate for developers, the temptation to regard the older monitors, and not so incidentally, the 21 million users who surfer the web in the confines of that tiny screen which AOL calls a browser has a thing of the fact is living in dream world. Unfortunately, the truth is that we must still to design for the lowest common denominator or risk the results of our effort being erased by the back button. As for the lowest common denominator, is that 800x600 or 640x480 pixels?
According to a recent survey by StatMarket, 55% of all surfers have their monitors set to 800x600 pixels: a mark that seems to be holding steady over the last year. Resolutions of 1024x768 pixels are increasing at a nearly identical rate that the 640x480 screen resolution is disappearing although the exact portion of which is which is not known. Anyway you slice it, resolution is a wildcard held by 45% of your audience. Not an insignificant number now matter how you work the math.
One school of thought simply ignores users with older equipment because it offers for more freedom of design and fewer compatibility problems. There are even developers who argue that it's not worth worrying about since people with old equipment are used to having things look bad.
On the opposite side of the fence, there are those who design to 640x480 pixels. They restrict and modify their desired design in order to make the site useable and appealing to the broadest possible audience. So what's a wise Web whiz to do?
Analyze your target audience: If your focus is either high end or high tech, chances are the vast majority of your users have newer sizable monitors and design accordingly.
Designing sites with additional content for users who posses more viewable real estate. Nab a nifty auto detect script and viewer is simply diverted to appropriate version. This solution, inherently labor intensive, is a practical choice for smallish sites. But your clients' site is humongous? What's the best choice: big site or small, option number three is what we use in my office.
Design pages that degrade well set your benchmark for 800x600 pixel width but rather than ignore the smaller settings, construct your pages so they are fully viewable on 640x480 screens by setting tables or page widths to a percentage rather than a numeric value. Then, the key images and text, when nested internally in fixed width tables that max out at 600 will ensure the most important features of your page clearly viewable no matter how old or the new users' monitors is.
Since now you have established the parameters of your page, what about colors, fonts, graphics and navigation? Well, that's why they call this column a regular feature: See you next month!
Employment, Revolution, Convergence and You
It's no secret that today's workforce is not your father's Oldsmobile. It's no surprise the workplace of today is immensely different from the workplace of 1950. But the evolution seen just in the past ten years is as colossal. The major influence in the evolution, of course, has been technology. Everything, EVERYTHING, is bigger, faster and better than it was yesterday...
How about an introduction? My name is Margaret Ortiz. I am the Market Manager in Florida for Randstad Creative Talent. I am honored to be able to contribute to the cfug-sfl newsletter. My aim is to bring an insider's perspective to the evolving workplace and address the issues YOU want to know more about. I encourage you to send me ideas and suggestions. I also encourage you to disagree! I hope you not only enjoy this column, but that you also find it useful. So, if you don't mind, I'd like to use this inaugural piece to introduce Randstad Creative Talent and the position we take in the evolving workforce.
It's no secret that today's workforce is not your father's Oldsmobile. It's no surprise the workplace of today is immensely different from the workplace of 1950. But the evolution seen just in the past ten years is as colossal. The major influence in the evolution, of course, has been technology. Everything, EVERYTHING, is bigger, faster and better than it was yesterday. Never have we been inundated with so much information. Never have employees had so much control over their destinies. Never has it been such a struggle to juggle the priorities of life and work. Never has the workforce been met by such rapidly changing skill sets and demands from employers, requiring workers to stay 'one-step-ahead' in order to maintain viability. Never has the workforce been so diverse in terms of age, gender, ethnicity and influence. And never has interpersonal relation been so lost. Talk about a perfect incubator for fallacy, misconception and misunderstanding.
Myths based on the traditional way of working collide with the realities of today's workforce. Motivations, attitudes, personalities and influence are vastly different across the generations. Surprisingly, there are quite a few motivations that are shared between generations. However, much of what is shared is lost in the struggle as the old and the new converge. "So what," I hear as the collective moan. Every generation rebels against the one which preceded it. We are destined to rebel against what came before us, just as we are responsible for maintaining these attitudinal changes and protecting it from the next generation's rebellion. So what! Yeah, it's not a big deal; until you realize the effect these generational agendas have on the WORKFORCE.
Enough about the Revolution, and back to the evolution. The evolution, buoyed by a continued strong economy and the lowest unemployment rates in history, has allowed the workforce to seek a better balance between their personal lives and their careers. Thus empowered, employees are demanding better understanding from employers concerning their need to find the perfect balance. Flexibility is the mantra of the current workforce. Flexible schedules, responsibilities, benefits, leave, training and challenges. Portable offices, telecommuting, job sharing, FlexTime, nor-traditional perks and stock options are all perfect illustrations of the effect of worker's demands for flexibility. Employers that are progressive and consider themselves learning organizations recognize these trends. They promote continual training, flexible schedules, onsite benefits (such as daycare, cafeterias, showers, etc), creative vacation time, child and elder care time-off, job sharing, and team work environments. It's these companies that will survive the evolution and be able to attract and retain the Top Talent.
All right, so it's no secret that today's workforce is empowered to seek the balance between life and work. But let me surprise you one more time for today, the workforce is looking to employers to take a larger role in facilitating that balance. Therefore it is crucial that employers understand more about employees and the balance they are attempting to achieve. It is essential for employers and employees to understand the differences and similarities in attitudes in a very diverse workforce.
Randstad North America (RNA) commissioned Roper-Starch Worldwide and Ringo Research to conduct a groundbreaking research effort to support or disclaim the very thoughts I've presented to you today. The RNA Employee Review: Insights Into Workforce Attitudes is the result of that research. The study was conducted nationwide in the US as well as Canada. And it's pertinent - across the board - even in the South Florida IT Market. The IT Market itself is the limiting factor to the research. The IT Market has, and will continue to do so for years to come, set its own standards and trends. The IT Market - due to the fact that it creates, develops, maintains and innovates the very element that has the greatest effect of change worldwide - has always been ahead of the trends. We might not always do things right, but we are the risk-takers, the mavericks and the innovators. And that goes for the South Florida IT Market as well, except we're just a bit behind. Yeah, I know, it's painful. But it's the reality. And, you can think of it this way; if you are already on the leading edge of technology nationwide, your intellectual property makes you a near Futurist in South Florida.
The information in the study and comparing and contrasting it to the trends in the South Florida IT Market is what I'd like to share with you in upcoming issues. This is where I need your feedback. Interested? Let me know at Margaret@estaff.com
Topics for future issues
From the RNA Employee Review:
A New Definition of Loyalty: Myth v Reality
Generational Influences in the Workplace: Us v Them, and Them, and Them.....
Workplace Myths and Realities: A Generational Perspective
Randstad Workstyles: Autonomists, Loyalists, Strivers, Yearners, Seekers and Shifters.
Other Topics:
Behavioral Event Interviewing: Even Contractors Need to Understand BEI
Consulting Careers: Getting Paid for Your Intellectual Capital
Soft Skills v Hard Skills: So You Have the Hard Skills, But Wont Get the Job Without The Soft Skills
The Portable Office: Working From the Beach
Project Management for Contractors 101
STL_Tag
The C++ Standard Template Library (STL) with its rich set of containers, iterators and algorithms should be a consideration to help facilitate your Cold Fusion CFX tag development. The use of STL is likely to make your tags more reliable, more portable, and more general, therefore reducing the cost of producing them. Other benefits include support for OOP concepts, function and class instantiation for any data type - user defined or built-in, and increased performance.
The C++ Standard Template Library (STL) with its rich set of containers, iterators and algorithms should be a consideration
to help facilitate your Cold Fusion CFX tag development. The use of STL is likely to make your tags more reliable, more portable,
and more general, therefore reducing the cost of producing them. Other benefits include support for OOP concepts, function
and class instantiation for any data type - user defined or built-in, and increased performance.
Ben Forta, in his book 'advanced ColdFusion 4.0 application development' walks us through the development of a
CFX tag 'ListRemoveDuplicates' (3 guesses on what this tag does) using both Visual C++ and Delphi. I'll highlight
portions of his Visual C++ implementation to illustrate the simplicity in which the STL can be incorporated.
(For a through discussion of the tag refer to the text).
After some preliminary parameter verification, the tag attempts to identify the distinct values from the original
list of values (from request.cpp advanced application development, pg. 170):
CCFXStringSet* ssList = pRequest->CreateStringSet();
char* ThisItem = strtok((LPTSTR)lpszList, lpszDelimiter);
while(ThisItem != NULL) {
if(ssList->GetIndexForString(ThisItem) == CFX_STRING_NOT_FOUND) {
ssList->AddString(ThisItem);
}
ThisItem = strtok(NULL, lpszDelimiter);
}
All the work is done within the while loop
as the original list is traversed each member is passed
as a parameter to the StringSet method GetIndexForString(). If the function fails the current string is
added to the StringSet ssList. Upon completion ssList contains all the distinct values of the original list.
To implement the STL, the beginning of request.cpp must be modified as follows (additional lines are in bold-type):
#include <stdafx.h> #include <cfx.h> #include <list> #include <algorithm>
using namespace std;
listtList;
list::iterator iter;
Cstring csNewList = " ";
The line "using namespace std;" cannot be ignored. It is required to avoid name clashes especially when a program consists of many files. We will incorporate the STL list container, which is implemented as a doubly-linked list for efficient add and delete operations.
STL implementation:
char* ThisItem = strtok((LPTSTR)lpszList, lpszDelimiter);
while(ThisItem) {
iIter = find(tList).begin(), tList.end(), ThisItem);
if(iter == tList.end()) {
tList.push_back(ThisItem);
}
ThisItem = strtok(NULL, lpszDelimiter);
}
The STL implementation is more reflective of the emphasis of the particular problem. We are trying to "find" a particular value in a list if it is not there, store it there.
Finally, the C-style list must be converted back to a Cold Fusion style delimited list. In other words the list of distinct values must be passed back to the calling template.
StringSet implementation:
for(int Counter = 1; Counter <= ssList->GetCount(); Counter++) {
csNewList = csNewList + ssList->GetString(Counter) + lpszDelimiter;
}
STL implementation:
iter = tList.begin();
while(iter != tList.end()) {
csNewList = csNewList + (*iter) + lpszDelimiter;
iter++;
}
Both implementations successfully create a string that can eventually be coerced into a CF-style list.
Notice in the StringSet snippet that two function calls are required, whereas in the STL code, only a single iterator dereference is required.
Even in this trivial example the performance gains using STL are strikingly evident.
Obviously, we cannot do an exhaustive study on the STL, but I have tried to present some of the motivations for its use for CFX tag development, to demonstrate in a small way its expressive power and flexibility, and maybe even whet your appetite enough to download a copy and explore even further this comprehensive library.
"Fuse-Data" Conceptual Whitepaper
In the world of business rules here, remote data there, and platform independent front-ends all over the place - sometimes it gets a little insane trying to figure out a great way to implement an easy solution (and I think there really is one!)
This white paper details how you can create data-management engine in cold-fusion
| Overview In the world of business rules here, remote data there, and platform independent front-ends all over the place - sometimes it gets a little insane trying to figure out a great way to implement an easy solution (and I think there really is one!) This white paper details how you can create data-management engine in cold-fusion. This method is employed by: sending a URL request into the engine, which then processes a specific CFM file, a wddx-encoded packet is then returned, containing either status information or a recordset. The system is fairly straight-forward, so there are not many features, and the instructions will be brief - especially as this is a conceptual document, and not a book :) Again, this whole document is a concept, not a "hard-coded practice"e;. This means, work through the sample, get an understanding, and adapt it how you see fit and practical! Again, keep in mind the information here is a guideline - it can be applied to other types of development technology just as easily. Some features
Technical Overview
Future Features
Sample Cold Fusion Engine Code application.cfm
This is the application.cfm file. This file handles the global variables, the session management and active connections, and the access validations (user login authorizations, whatever you want call it). If access validation is to be performed, it will check to see if you have an active session. If you do, you will be validated, if you are not, your session will indicate you have an expired session, and will pass the message to the underlying file (preventing the user from accessing the file). This piece of code demonstrates how I manage the login process. This is used to validate the user, and then create their special encrypted session ID.
loginprocess.cfm
The next chunk of code represents the actual file that will be called by the calling application. As you may be able to tell, the cfparams indicates which url variables will be required. Sample methods of use To reiterate a little - the cool thing about this concept, you can create the flexible business logic, and fairly easily, in a language you understand. And this business logic, along with all related databases, com objects, functions, etc., is all accessible via any application/system that can read and post html pages. This concept can be (and should be), applied to other areas of development. This concept can make a great addition to your fusebox methodology, or is something to think about if you are creating a new internet-based application (like a VB program). BTW - This is a "first" version, so there may be some bugs or weird thing (I did modify the code a little for visual reasons. |