Excerpt: Introducing ColdFusion
Chapter 1: Introducing ColdFusion
Let's begin with a basic fact that will put your upcoming 21-day journey into perspective, and maybe even make it less wearing on your psyche: ColdFusion is all about saving time.
Like other Web development and application-server tools, it was developed by people like you and me who grew tired of living in their computer chairs, folks who wanted to get their projects finished and get out to see the world.
The 21 days you now begin to invest will pay off later in the form of time spent doing things other than hard-coding HTML documents and formatting boring text passages. How you spend that free time is entirely up to you, and way beyond the scope of this book.
In Day 1, you'll:
Get your first look at Allaire's ColdFusion.
Learn how it can make you the talk of your computing buddies and find out whether it's the right tool for your project.
Cover the basic theory behind creating dynamic pages.
Look briefly at the client/server relationship that makes all this high-tech wizardry possible.
What Is ColdFusion?
A couple computer types, brothers Jeremy and J.J. Allaire, created ColdFusion in 1995. Jeremy, the business-minded one, had a print publication he needed to regularly post to the Web, so he approached the coding brother, J.J, and asked him to help build a simple application that would speed the task. When the project was complete, both realized they had a hot property on their hands and Allaire Corporation was born. Today, ColdFusion is in its fourth major release and both brothers wear fine suits and drive fancy cars.
The official description of ColdFusion calls it a Web application server, but depending on how you choose to use it, it can also be considered a page-development tool, a database server, or your ticket to the high life. At the heart of the program is a database-to-Web gateway. It allows you to take an existing database file and serve it up via the Web, record-by-record, without having to create new HTML files for each record.
Exploring a Sample ColdFusion Application
To clarify this concept, let's use an example. Using a common database program, Microsoft Access, I've been maintaining a database of Elizabeth Taylor's husbands, as illustrated in Figure 1.1.
Figure 1.1. A sample database table in Microsoft Access containing data on the men in Liz Taylor's life.
New Term -- A field is an element in a database that categorizes information by type. If I create a database containing names, occupations, eye color, hair color, and net worth, I'd define each of these types as a field.
Now assume that I've decided it's vital that the world has this information readily available. The traditional way to get this stuff on the Web would be to sit down, fire up the text editor, and start coding HTML documents, seven in all or eight if you count the fact that she married Richard Burton twice.
But, hey, I know that creating seven or eight Web pages with the same type of information on each is a waste of my time. Instead I'll use ColdFusion to create the pages dynamically.
New Term -- Generating a page dynamically means to create it on-the-fly, or at the moment it is requested by the user's browser. The opposite of a dynamic page is a static page, or a plain old HTML document that physically resides on a server.
I upload the database to my ColdFusion-compatible Web service provider, set it up as a datasource (don't worry, I'll get to this in Day 3, "Setting Up ColdFusion and Defining a Datasource"), and then create a single template file to serve up the information.
New Term -- A ColdFusion template file is a Web page that contains text and code directing ColdFusion to perform an action or actions. Templates use the file extension .CFM.
When someone accesses my template file from the Web and requests the record for the little-known Larry Fortensky, it looks like Figure 1.2.
Figure 1.2. ColdFusion output for the database record containing "Larry Fortensky".
Looks a lot like a regular Web page, right? That's an important point to catch -- ColdFusion is transparent to the end user, save for the file extension .CFM instead of the standard .HTML. Because it's a back-end application, the average surfer won't even know you're using it. He'll think you spent hours building pages just for his benefit, and that's not necessarily a bad thing.
New Term -- A back-end application is one that runs behind the scenes and is transparent to the Web surfer. Various back-end apps are used to serve Web content, to gather data on site visitors, and to control advanced features such as chat rooms, message boards, and so on.
Why Should I Use ColdFusion?
Hopefully, at this point, light bulbs are popping over your head and bells are ringing in your ears with reasons to use this great tool on your own projects. Just in case there aren't, in the next few sections I'll cover a few reasons why ColdFusion is a tool you will want to add to your repertoire of development applications.
ColdFusion gives you the ability to control some of or all of your entire Web site's content from a database. The beauty of this may not strike you just yet, but consider a situation where you might be working with others who aren't as HTML-savvy as yourself. Without ColdFusion, a change in content means that someone has to come in and code a new HTML page, and that someone will probably be you, regardless of the importance of whatever you were doing when your pager went off. With ColdFusion, Web content can be changed or updated by anyone who knows his way around an input form and an enter key. This means that anyone in the company -- even those without database experience -- can update their Web projects without you having to drive down to the office and possibly miss the bonus round on "The Price Is Right."
In addition, database-driven sites give you the ability to present lots and lots of material on the Web, and you only need to design a single template file. Take my Liz database, for example. It's pretty small now, but someday if that database should stretch into hundreds or thousands of husbands, my initial template page would easily handle all of them. I'd have one killer Web site that looked as if I'd spent hours designing pages.
Database-driven sites also present interesting opportunities to keep tabs on your visitors. If your site required users to register with a login name and password, for example, you could then use the database behind the scenes to track their interests by logging the pages they visit. The concepts behind this are covered further in Day 7, "Changing the Contents of a Database with ColdFusion."
Ready for Business
Many businesses love databases, and these businesses may come to love ColdFusion. It's not hard to see why. Many businesses maintain a database of their products or services, and for an existing database, ColdFusion makes it a short hop to a full-featured Web site. Show me a business with a large product catalog and I'll show you, the Web developer, a quick way to deliver a full-featured Web site that will have your client dancing in the streets.
Real-Time Web Presentation
Many businesses can use ColdFusion directly with their active databases. This means that the moment someone in the warehouse records a product as shipped, the pages on the Web site immediately reflect the change in inventory. In most cases, businesses can continue to use the same database, spreadsheet, or word processing software they've always used in the same way they've always used it. Just imagine the reception when you march into a business and tell its owners that you can put their entire operation online in real-time -- without their forking over a cent to retrain employees.
Interfacing With Intranets
Due to the nature of their product or service, some businesses don't really require an extensive Web presence, but this doesn't mean that you, the ColdFusion developer, need to pass them by. Lots of businesses use ColdFusion as an intranet tool.
New Term -- An intranet is an internal network that is usually not available to Web users. Intranets are used within businesses for employee tasks such as information sharing, maintaining the company database, or vital communications such as "Hey, Jim in accounting, how was the big bash last night?"
Many businesses have found that using Web-like interfaces to control their intranets helps new employees assimilate quickly and easily. Many have at least experimented with a Web browser, so by presenting intranet data in the form of Web pages, businesses can avoid having to acquaint new hires with several applications.
ColdFusion is ideal for building these Web-based interfaces, and its database functions are just as valuable on intranets as they are on the Web outside.
Site security is generally a pretty big concern for businesses, whether it's keeping the advertising staff from rewriting editorial copy or keeping outsiders from rifling through the company secrets. ColdFusion has several security measures built in to the program, meaning that even inexperienced CF designers don't need to worry much about leaving their sites open to hackers and ne'er-do-wells.
ColdFusion is e-commerce ready, with lots of built-in tools and tricks that make it easy to build sites offering secure online transactions. I'll cover this in depth in Day 20, "Using ColdFusion for E-Commerce Applications," but for now just let the concept sink in. We have a tool here that allows you to quickly serve up a huge database of products or services, plus the ability to easily make them available for sale online. Bells ringing yet?