ColdFusion Architecture For RIAs - Part 1

This is the first of a series of four blog entries I'm writing to demonstrate CF in a RIA architecture. Each entry will take a "plain" ColdFusion application and show how it was necessary (or not) to modify the code to handle the requirements of a "Web 2.0" application. This first entry is an overview of traditional vs. next-gen web applications and is an introduction to the "plain" CF application that will be the starting point for the other three "Web 2.0" applications I describe in the next three posts.

The necessity to deploy Rich Internet (or "Web 2.0") Applications is a fact of life these days. They often deliver better ROI and competitive advantage, and today's web citizens expect and sometimes even demand a better user experience. The flash platform is, at least without a doubt in my mind, the ideal platform for delivering these applications. Some companies and developers prefer to use AJAX - and if it does what they want then that's fine for them. I'm not writing to debate the merits of one technology versus another (not today, anyway). What I want to write about is the impact that this has on the architecture of a typical ColdFusion application.

On several occasions in the past years I've written about the role of CF, in the context of next generaion web apps, changing from that of a "presentation server" that is also capable of performing business logic to that of a "service provider". For the most part this is true in the case of "Web 2.0" applications - except for those scenarios where CF is generating the RIA presentation layer (i.e. CF is creating the code for an AJAX front-end using the new CF8 CF-AJAX tags or is dynamically generating other AJAX or possibly Flex interfaces). Even then, though filling the role of presentation server, let's assume for argument's sake that CF is also filling the role of service provider. So how does all this impact the architecture of your CF application?

We'll start with a very simple address book application written entirely in CF. You can download this code at http://www.horwith.com/downloads/abook-cf.zip. To test, first extract the zip file to a web root served by ColdFusion. To set-up the application as-is, run the "create-sql-server-db.sql" file against a SQL Server 2005 database, then run "create-db-tabls.sql" against that database... create a datasource in the CF Admin named "abook" that points to the new database, then browse "populate-db.cfm" to populate your new database. All of the database related files are in the "build-db" directory created when you unzip the zip file. You can browse the application simply by browsing the "index.cfm" file in the "abook-cf" directory created when you unzipped the compressed file. There's nothing "Web 2.0" about it. There's a .cfm that shows all the entries in our address book, with links to filter by first letter of last name and links to edit records, and there's a .cfm that displays a form for adding and editting address book entries. There are also 4 ColdFusion Components, which are the "meat" of the application:
  • addressbook.cfc - represents an address book
  • addressbookentry.cfc - a data transfer object (DTO) representing an address book entry
  • addressbookdao.cfc - the parent class of all address book Data Access Objects (DAOs)
  • addressbookmssqldao.cfc - the address book DAO containing all the CRUD methods for SQL Server
Not only is there nothing "Web 2.0" about this code, but I should also state for the record that I had no intent of using it in a "Web 2.0" environment. It was actually written as part of an object orientation code exercise I conducted at Nylon Technology. This fact only makes it an ideal candidate for use in illustrating the impact of leveraging "legacy" code in next-generation applications. All of the data is cached in the session scope - the idea being that when a user logs-in, their address book(s) are loaded into the session scope and synchronization with the database actually happens behind the scenes. It's worth mentioning that to keep things simple I've taken 2 shortcuts. First, there's no actual log-in... in the real world you'd force a log-in and, at that time, select the address book IDs for all the address books owned by the current user. Second, since there's no log-in, the code is hard-wired to assume that for any request the address book ID from the database is 1. You can see this defined in the Application.cfc "onSessionStart" method.

Registration is now open for the FigLeaf 'Top Gun Conference'

Once upon a time, the very talented folks at FigLeaf Software offered 'Top Gun' Training. In recent history, they began an annual 'Flex Maniacs' conference which became the 'Web Maniacs' conference. This year they've resurrected the 'Top Gun' naming and re-branded the conference as the 'CF & Flex Top Gun Conference', which is actually 3 one day conferences back to back. Day 1 is CF and AIR, day 2 is CF and Flex for Newbies, and day 3 is Flex and AIR.

Registration is now open - you can get one day passes for $199 or a 3 day pass for $499. Registration is online at https://training.figleaf.com/topgun/registration/index.cfm.

These days I'm very selective about what conferences I endorse and even more selective about which conferences I'll attend. I'm happy to say that I will be attending and speaking at the top gun conference, as I feel that of all the conferences this year, it's the best deal out there for the developers.

Ricky Robinett on PHP and AIR

Ricky Robinett, who is a Zend Certified PHP developer and an Adobe Certified ColdFusion Developer who works with me at Nylon Technology, has just published a great article about using PHP and AIR to power desktop applications. You have to shell out $3 to get the PDF (or buy the print copy when it is on the shelves next week) - http://phparch.com/c/magazine/author/294.

AS3 Reference for the iPhone

I just read about this on Sarge's blog so I checked it out. Mike Chambers has created an AS3 reference for the iPhone. Nice, Mike. You can read all about it on Mr. Chamber's blog at http://www.mikechambers.com/blog/2009/01/26/actionscript-3-reference-for-iphone/#more-1648

Two Events To Learn Flex on a Budget in September

There are two upcoming events that are both a great deal for anyone who wants to learn Flex on a budget. The first is bFlex (http://bflex.info/) - a free hands-on training event in Bloomington, Indiana on Sept. 7th (preceded on the 6th by bFusion, a free day of ColdFusion training). The second event is 360 Flex NJ (http://www.njflex.com/) - a 2 day Flex event being held on Sept. 26 and 27 just outside NYC in Montclair, NJ and offered at just $75 a day (day one is a single all-day training session and day two is composed of several sessions from well known speakers in the area).

The great frameworks debate

This past week at the New York Flex User Group, Yakov Fain compared and contrasted 3 Flex frameworks (Cairngorm, PureMVC, and Mate). Yakov also showed an application his company is planning to release that is a code generator - creating both server and client side code (very similar to the Flex Builder CF wizard for building an LCDS app, only a bit more robust in the amount of code it generates and the options for server side technologies). The evening began with a quick examination/explanation of Flex itself, as a framework.

Attendance was great (60 people) and audience interest and participation was extraordinary. When the end of the presentation turned to an open discussion, it took very little time for the age old frameworks debate to ensue. Those of you who know my love for stirring the pot when it comes to topics like this may be surprised to know that I didn't get too involved in the actual framework "yes-no" side of the discussion. Even so, it felt funny being outside the CF world and getting stuck in the middle of the same religious debate that we CF developers are all too used to.

Actionscript is a language that I feel frameworks can bring a lot to when architected well... but I also feel that the Flex Framework alone is sufficient for most projects - especially given the size of the average Flex app. That said, I had never seen Mate before and after seeing Yakov's preso. thought that it looked pretty slick - I definitely plan to take a closer look at it sometime soon.

Getting back to the meeting itself, conversations lasted well over an hour after the meeting had ended. Though I don't want to fuel any fires, it's hard to ignore the enthusiasm and attendance witnessed at the meeting. So, I'm planning to hold a debate on Frameworks in Flex at an upcoming meeting. It will be a properly run debate with tables, time limits, and moderation. If anyone who reads this feels strongly about the topic of Flex frameworks (on either side of the argument), and thinks they'd make a good member of the debate at the table, please let me know (simon at horwith dot com). As soon as I've got a good team for both sides of the debate, I'll schedule it for an upcoming meeting.

Hiring Developers in New York

This isn't a very formal job posting - email me at shorwith@nylontechnology.com for more information.

My company, and a sister company, have several positions to fill. I need developers from mid-level all the way through CTO level types - primarily ColdFusion but I'm also looking for people to do Flex and AIR, and I've got need for some solid PHP talent, too. Oh, and I'm also looking to hire another Project Manager. With such a broad range of skills and skill levels, you can see why I'm not posting anything too descript.

These positions are all in New York City - so I'm looking for folks who either live in New York or want to relocate to New York.

They all involve working in a fun environment with great developers, and there's definitely growth potential. Like I said, write me if you're interested in knowing more and pass this along to anyone you know who might be interested.

Flexing with Joe

If you read Joe Rinehart's blog (http://www.firemoss.com/blog/) then you already know this, but I thought I'd also let folks know that Joe and I are joining forces to teach a pre-conference class on Flex for ColdFusion Developers at CFUnited. Joe and I are both long time fans of ColdFusion who have been devoting a lot of time to Flex in recent years.

Class information (and registration link) are at http://teratech.com/go/training/class-schedule?trainingaction=detail&TID=335. If Flex is something you've been wanting to pick-up, this is definitely a class not to miss.

What I've Been Up To

After returning from my latest trip to India, I'm finally begining to break my long radio silence and blog again. I've spent the past 5 or 6 months really trying to grow professionally and technically. So, what have I been up to?

Professionally, over the past decade I've served every role from Senior Developer to Architect to CTO and CIO. About 2 years ago I spent a good amount of time getting more and more active in business development - a role that makes sense given my love for public speaking. I thought the time had come to grow a bit, so I've spent the past 5 or 6 months functioning almost entirely (I do still write code, though) in a sales capacity. Sales is more challenging, or at the least more frustrating, than business development, but it's essential to any business and I thought it was high time I learned it first hand. I learned 2 things from the experience. One is a new found respect for the job sales people do at solutions companies. The other is that I don't ever want to be a full time sales person. Still, if I'm going to function at an executive level for IT companies, it's important I not only understand/appreciate the role of sales, but also that I intimately understand what it is that they do day-in and day-out.

Technically, I've been extremely busy. I've read, studied, and digested every piece of literature available on the subject of user experience. I've gotten into interface driven application design and tried my hand at putting all these theories into practice. I've been using Flex and AIR a lot as well as AJAX - trying to weigh up the pros and cons of each as well as put CF into the picture for a perspective from the server-side developer's point of view. I've also been taking a lot from what I've learned from LISP and my studies in Object Theory and as a result have been giving a lot of thought to what I would like to see improved in CF as well as to how these ideas might be applicable in ColdFusion development right now.

There's a lot I plan to write about as a result of my past 6 months of exploration, and hopefully I'll find the time in the near future. In the interim, I'm also now actively seeking to take my attention away from theory and away from sales and get back to doing what I do best - writing code and leading IT shops.

Flex and Air in New York City

About 3 months ago, my buddy Shlomy (http://www.shlomygantz.com/blog/) who manages the New York City Flex User Group (http://www.nyflex.org/) asked me to take over as manager indefinitely while he is overseas. Those of you who are already members of the group are most likely already aware of this news but I thought I'd let the rest of the world know. Anyone interested in presenting topics should email me at simon@horwith.com

The next meeting will be the NYC stop of Adobe's Flex 3 / AIR Pre-release Tour. Dave Gruber and Tim Buntel are tag team presenting the meeting, which is on Wednesday, January 23rd at 6:30 PM at the Avenue A|Razorfish offices (1440 Broadway 19th Flr.). I am still in India on vacation but will be back in the U.S. for the meeting.

More Entries

This site is hosted by HostMySite and runs off of BlogCFC - thanks, Ray.