Adobe Day – Washington DC

Adobe Days are free events designed to introduce you to various players on the Flash platform. Next week in DC we’ll be doing one focusing on Flex and ColdFusion.

I’ll be attending, lending moral support to Ryan Stewart. And by “lending moral support to” I mean “learning the ropes from”.

So if you’re in DC and are looking for a good and free overview of what Flex can do for you, c’mon down.

Adobe Day Washington, D.C.
Thursday, February 26, 2009
9:30 a.m. – 2:00 p.m. EST
Agenda

Grand Hyatt Hotel
1000 H St NW
Washington DC 20001

Registration is free.

Link: Adobe Day Washington DC

ColdFusion Has Many Roles to Play

Finishing up my series on my idea of why I am drawn to ColdFusion is my final point – ColdFusion has many roles to play. ColdFusion doesn’t force you to use only it for all layers of your web application. You can selectively choose to use ColdFusion for as much or as little of your application as you want. ColdFusion doesn’t just allow this, like everything else, it makes it easy. Off the top of my head here are some uses cases for ColdFusion in your application:

  • Traditional HTML generated application by ColdFusion
  • Complete client layer using built in ColdFusion AJAX components
  • Back end to AJAX driven front end using cfajaxproxy
  • Back end to Flex application using Flash Remoting or LiveCycle Data Services ES
  • Bridge between your application and messaging services (JMS, SMS, XMPP) with Event Gateways

Let’s start with the traditional HTML generated application:


SELECT *
FROM app.artists

Name City State
#firstName# #lastName# #city# #State#

Sure, I can just take a query and pass it to an HTML renderer and… instant data screen. ColdFusion can do the entire thing. But that code would provide a poor user experience. That table is pretty much just phoning it in. Instead, I can use ColdFusion’s built in AJAX features to make a better UI using a datagrid.

First I have to move the query to a CFC, and run it through a simple function that formats the data for the datagrid:

SELECT *
FROM app.artists

Once that is done, I can call that CFC from a datagrid component:

Or I can instead opt out of using ColdFusion UI components, and either roll my own or use an established framework (both using cfajaxproxy):

var cfData = new cfData();
cfData.setSyncMode();
cfData.setQueryFormat('column');

datatable = document.getElementById('dataTable');
res = cfData.list();
table = queryToTable(res);

datatable.appendChild(table);

function queryToTable(result){

table = document.createElement('table');
tbody = document.createElement('tbody');

for(i=0;i<res.ROWCOUNT;i++){
row = document.createElement('tr');

cellFname = document.createElement('td');
txtFname = document.createTextNode(res.DATA.FIRSTNAME[i]);
cellFname.appendChild(txtFname);
row.appendChild(cellFname);

cellLName = document.createElement('td');
txtLName = document.createTextNode(res.DATA.LASTNAME[i]);
cellLName.appendChild(txtLName);
row.appendChild(cellLName);

cellCity = document.createElement('td');
txtCity = document.createTextNode(res.DATA.CITY[i]);
cellCity.appendChild(txtCity);
row.appendChild(cellCity);

cellState = document.createElement('td');
txtState = document.createTextNode(res.DATA.STATE[i]);
cellState.appendChild(txtState);
row.appendChild(cellState);

tbody.appendChild(row);

}

table.appendChild(tbody);
return table;
}

If, however, I wanted to go with something other than HTML/JavaScript for the front end, I still have options. ColdFusion is perfectly suited to act as a back end for Flex. In fact that CFC above still works with Flex. To call it from Flex I just have to point an end point to it and add a datagrid:

But let’s say that you instead wanted to interact with some sort of other interface like SMS, JMS, or as in the following example, an XMPP client using Gtalk:

That’s a lot of mileage out of that little query. From that simple query, I’ve rendered a plain old HTML page, a ColdFusion AJAX display page, a custom written AJAX-driven page, a Flex display component, and a Gtalk Bot. That’s what I mean by ColdFusion can play lots of roles. It can do the whole thing, or just part of it. Combine that with the concepts in my previous post, and ColdFusion can do the following:

  • Act as a front end to business logic written in Java or .Net
  • Act as a back end to a front end written in Flex or HTML/Javascript
  • Act as a messenger from a back end written in Flex or Java to a front end written in Flex
  • Act as a messenger between all of these and a messaging service
  • And of course, it can be your front end, back end, and messenger all in one

The idea here is that when you use ColdFusion, you can either use it full hog, or selectively swap in technologies that better address your needs. ColdFusion doesn’t lock you in; quite the opposite, it opens doors for you.

ColdFusion Plays Well With Others

Continuing on with the series I started on Tuesday, I’m going to explore ColdFusion’s ability to play with many other technologies, and do so very well.

First, let’s start with what ColdFusion was designed for, getting information out of databases. ColdFusion ships with drivers for talking seamlessly to the following database systems:

  • Apache Derby    
  • MS Access    
  • MS SQL Server    
  • MySQL     
  • PostgreSQL     
  • DB2
  • Informix Dynamic Server    
  • Oracle
  • Sybase

Does that mean if you are a FoxPro or SQLite developer, you’re out of luck? Hardly – if it has a JDBC driver you can talk to it with ColdFusion.

Databases are only a portion of what you have to deal with, especially if you are talking to back end systems with various interfaces. The can include directory servers, file servers, mail servers, etc. Here’s a non exhaustive list of ColdFusion tags that can talk to those sorts of servers:

cffile, cfdirectory 

Both local and remote file stores 

cfexchangecalendar, cfexchangemail, cfexchangeconnection, cfexchangetask, cfexchangecontact, cfexchangefilter

Microsoft Exchange Servers 

cfftp  

FTP and SFTP servers 

cfhttp 

Other web servers, REST webservices 

cfldap  

LDAP Directory services, Active Directory 

cfmail, cfmailpart, cfmailparam 

SMTP servers for sending mail

cfobject, cfinvoke

SOAP webservices 

cfntauthenticate 

Active Directory for authentication purposes 

cfpop 

POP3 Mail servers for acting as a mail client 

cfprint 

Any printer accessible by the ColdFusion host 

 

That’s a pretty big list. Keep in mind that it’s not just about talking to those services; it’s about easily talking to those services. Yesterday, I showed the cfexchange tags and cfmail tags in action. They’re all pretty much that easy and concise to use.

Next, ColdFusion can call just about anything that can be run from the command line via cfexcecute:

#results#

That’s not necessarily compelling. Pretty much every programming tool can make calls to the shell. But I think it’s important to point it out, keeping in mind that this is a must have feature for any tool.

But shelling out to the OS, running a command, reading it into a variable and parsing it is a pain. It’s a lot of extra coding, extra bug trapping, and usually a performance hit. So it would be nice if you could interface with certain other tools without having to do that.

I kinda, gave a sneak preview of some of this content the other day, when I showed getting information from .Net into Java in two lines of code:

I didn’t have to import any libraries to accomplish this, it just worked from the moment I installed ColdFusion. I consumed a .Net assembly, got a string from it, and passed it a Java Object. That was just a string, but if the return had been a more complex object, ColdFusion would have converted it to a native ColdFusion structure. Any errors would have been caught and delivered via ColdFusion’s error handling mechanism. The same applies to the Java call.

The .Net communication was added in ColdFusion 8, but the Java communication has been around since ColdFusion MX 6. The reason behind this is the often overlooked fact that ColdFusion is written in Java, runs on Java, and can be looked at as Java framework. Anything Java can do, you can get done in a ColdFusion page or component. You might have to drop down to coding in Java to do it, but that’s pretty easy to do:

#result#

As you can see, I can use the result generated by Java without any special conversion.

Finally, ColdFusion can run with support from Adobe on many platforms:

  • Windows
    • Windows XP
    • Windows Vista
    • Windows 2000
    • Windows 2003
    • Windows 2008
  • Mac
    • OS X 10.4, 10.5
  • Linux
    • Red Hat 3.0, 4.0, 5.0
    • SUSE 9, 10
  • Solaris
    • Solaris 9, 10
  • AIX
    • AIX 5L, 5.2, 5.3

Those are just the supported platforms. It’s also quite possible to run CF on Ubuntu or Centos. (But I must stress, Adobe doesn’t support these distros of Linux, yet.)

I hope, I was able to show you in this long, but frankly shallow overview, that ColdFusion can talk to a lot of different system, using many different interfaces, and do so on pretty much every mainstream platform you could need.

Queries are the Secret Sauce of ColdFusion

Kevin Hoyt commented on my blog post yesterday about ColdFusion Makes Hard Things Easy. He reminded me of a feature of ColdFusion that gets overlooked because it is so elemental to the language: the query variable.

In ColdFusion results that are returned from database get returned in a query variable. Query variables are an implementation of the iterator pattern and have a few special properties:

  • Queries map columns from the database into easily addressable properties
  • Queries also have the obvious properties named recordCount, currentRow, and columnList
  • Queries have hooks to that cfloop and cfoutput can iterate over them
  • Properties of queries can be addressed easily within an iterating process

That’s all a really complicated way of describing what happens in this code:


SELECT firstName, lastname
FROM app.artists

#qry.recordCount# records returned with columns named: #qry.columnList#

#currentRow# of #recordcount# - #FirstName# #lastName#

You see, the first cfoutput tag didn’t have a query attribute, so I had to prepend the properties recordCount and columnList with qry. Later when I was iterating over the query using cfoutput, I didn’t have to bother prepending.

That’s cool, and easy, but not outside the realm of what you can do in other languages. So let’s get to what Kevin mentioned in his comment Query of Queries. Query of Queries refers to ColdFusion’s ability to use a ColdFusion query as a table against which to perform SQL in another query. Want to get all of the records from the previous query that begins with A:


SELECT firstName, lastname
FROM qry
WHERE firstname like 'A%'

Want to get all of the records that begin with E:


SELECT firstName, lastname
FROM qry
WHERE firstname like 'E%'

Want to combine the A records and E records:


SELECT firstName, lastname
FROM anames
UNION
SELECT firstName, lastname
FROM enames

That’s right query of queries will let you do unions or joins too.

Now some of you might be questioning the usefulness of this. You think things like filtering, joins and unions are operations best handled by the database. You’re right they do. But, imagine that I was pulling data out of separate databases, perhaps one in Oracle, and one in MSSQL? You couldn’t do it in the database.

Also cfquery is not the only tag in ColdFusion that creates query variables. The others include (But I’m sure I’m missing some):

  • cfdbinfo
  • cfdirectory
  • cffeed
  • cfexchange tags
  • cfldap
  • cfsearch
  • cfstoredproc

That means you can take any of the results of these tags and filter and group and join them just the way you can with a database. Want to see all of the files in your directory and are not .cfm files:

SELECT *, directory + '/' + name as fullpath
FROM files
WHERE name not like '%.cfm'

#fullpath# #size# #datelastmodified#

That’s pretty easy, and I think that qualifies as something not every solution can do. It opens up the door to a lot of other possibilities:

  • Joining LDAP data to SQL Data
  • Creating a union of multiple RSS feeds
  • Joining data about stored files to SQL data
  • Joining RSS feed data to Exchange users

ColdFusion queries, and query of queries are powerful features that make one of the most common jobs in web programming – displaying some kind of retrieved record – shockingly simple. Add to it that the number of entities addressable in a ColdFusion query includes many other sources than just the database, and you have one powerful feature that is not easily matched.

ColdFusion Makes Hard Things Very Easy

This is not the first time I’ve made the claim that ColdFusion makes things easy. This has been my chief reason for loving ColdFusion from day one. I’m going to take a few tasks, and show you how easy ColdFusion makes them.

Get some data out of a database and display it on a page:


SELECT firstName, lastname
FROM app.artists

#FirstName# #lastName#

Querying from a database using CFQuery just feels natural and easy. I personally hate saving SQL to a string, then attaching it to query object that I then execute. Looping over the results of query is also simple and straightforward. I don’t have to worry about addressing the query in a collection or other structure, CFoutput handles looping over the results and pointing my call of “firstname” to the firstname column in the current row of the results.

Send a short email to someone:


This is a test message

Similar to the database query, sending mail from ColdFusion is just drop dead simple. More than that, it’s pretty intuitive. It’s hard to not understand what is going on here.

These are pretty standard, and most tools have patterns written for them to make this sort of basic functionality easy to write. So let’s take on some harder tasks.

Create a PDF from some content:

Hello World

I contend that printing a document to the PDF Print driver takes more effort than doing it in ColdFusion. Feel free to disagree.

Create an image for use in CAPTCHA testing:


Notwithstanding everyone’s hatred for CAPTCHA, that’s shockingly easy to create a CAPTCHA image.

Okay, again nothing we did was too crazy but you have to admit that is some really easy, concise, easy to comprehend code. Let’s do something a little harder.

Pull all appointments named “Lunch” from your Exchange Server:

I’ve said it before, the only way of working with Exchange that is easier than ColdFusion is Outlook.

Pass a result generated from .Net to a Java string for use by a custom Java Library:

Interoperability between .Net and Java, in two lines of code? That’s kinda ridiculous.

Now, to be clear here, I’m not saying you can’t do all of this in other languages, I’m saying this is the easiest I’ve ever seen it done. The team behind ColdFusion has done a great job of balancing between encapsulating the difficult, but making it easy to go beyond what they enabled. All of the tags used in the examples have many more attributes that you can use to fine to the behavior show off here.

This was a overview of how easy ColdFusion makes it to do hard things, in the next series post I will talk more about what you can do with ColdFusion when ColdFusion can’t do what you want it to do. (That’s not a typo.)

ColdFusion’s Advantage

Jeff Porten commented on my post about Getting Started Developing in ColdFusion and challenged me to show him how “does [ColdFusion] blow the doors off my existing toolset.” So I figured I would talk in greater length about the features of ColdFusion that made me a loyal customer and makes me believe in it enough to base my livelihood on it.

I think there are 3 major areas where ColdFusion blows away other toolsets that solve similar issues:

  • ColdFusion makes hard things very easy
  • ColdFusion plays very well with other technologies
  • ColdFusion can play many roles in a web application stack.

Instead of turning this post into a huge treatise on ColdFusion, I’m going to run a short series on these entries over the next week.

How to Get Started Developing in ColdFusion

I’ve seen a couple of tweets around this, and instead of trying to answer every one in 140 characters, I’m instead going to point people to this article.

Get the Developer’s Version of ColdFusion

The developer’s version of ColdFusion is free. It’s not a trial version; it is just free, but with a few restrictions. It is limited in the number of IP addresses it will answer to, and certain featured like cfdocument and cfchart get watermarks placed in their generated content. If you purchase a licensed copy, this version can be upgraded without a reinstall.

In addition to the Developer’s Version a Full trial version is available. It is not limited in ability, but will only run for only 30 days. If you purchase a licensed copy, this version can also be upgraded without a reinstall.

Download the free developer’s version or trial version of ColdFusion

Also I will point out that if you are a member of the Faculty, Student Body, or Staff at a Higher Education institution using ColdFusion for academic purposes, then you are eligible for a free license.

Apply for a free license of ColdFusion for Education.

Pick an Editor/IDE

There are a few options to choose from for editing ColdFusion. Obviously any text editor will work, but there are a few choices if you are looking for an editor with language support for ColdFusion.

Dreamweaver has color coding, language reference and RDS integration with ColdFusion. It is an especially attractive option if you are coming from another web technology and already working with it. If not you can also try it out its demo version.

Download the trial version of Dreamweaver

CFEclipse is a pretty full featured editor for ColdFusion. It is an especially attractive option if you are working with Eclipse already as a Java developer, or using Flex Builder.

Getting started with CFEclipse

Finally, although it is not available today, the Adobe project currently named “Bolt” is a ColdFusion IDE. I’d bet on it becoming the standard tool for ColdFusion development when it comes out.

Learn more about Bolt

Learn about ColdFusion

Pretty much everyone will point you to the Adobe ColdFusion Web Application Construction Kit, Volumes 1, 2, and 3. Combined they are pretty daunting, but you are just getting started, so buy volume 1 for now. Disclaimer: the first author of the book is Ben Forta, for whom I work. I would still recommend it even if I didn’t.

Get the book at Amazon

Also available is community member John Farrar’s book ColdFusion 8 Developer Tutorial. I haven’t read it, but check it out and see if it is more your style.

Get the book at Amazon

In addition to the book route, there is a ton of information available on the Adobe Developer Center. The include simple how to’s and higher level articles like theory behind high availability.

Connect with Other ColdFusion Developers

There are several ways to tap into the ColdFusion Community. Here are just a few:

Also deserving special mention is ColdFusionBloggers.org. This site was setup by Ray Camden, and is a ColdFusion only blog aggregator. Ray’s pretty aggressive about policing the list (and publicizing the site 😉 ) so in many ways it’s a better resource than AXNA.

ColdFusionBloggers.org

Get Open Source ColdFusion Code

A few years back Ray Camden started RIAForge as a place to store Open Source applications written for ColdFusion and Flex. Currently it has over 600 projects. Check it out before you try and reinvent the wheel.

RIAForge open source code for Adobe technologies

Online Video Presentations

There are a few collections of ColdFusion audio and video presentations by some of the best voices in the community.

I’ll add more to this as I find new ones, or people point out to me which obvious ones I’ve forgotten or not explained enough.

Name This Product

I’m going to do a little exercise. I am going to describe a product. Tell me what technology product I am talking about:

  • Niche product
  • Users are often derided for using it.
  • Outside pronouncements of its obsolescence are common
  • Users are passionate often to the point of zealotry.
  • Users claim to be much more productive because of it.
  • It holds a minority market-share.
  • It’s commonly criticized for costing more than the competition

So… What am I talking about?

Apple, what product did you think I was talking about?

I guess I’m trying to point out, that I’ve been thinking a lot about a particular product’s place in the collective common wisdom, and perhaps we need to change it. But before we change it externally, we need to make sure internally in the community, we know what we offer.