What's Wrong With ColdFusion - 2014 Edition

Well, it's that time again. Later this week is the second annual ColdFusion Summit, put on by Adobe. Last year, just prior to the summit, I posed the question What's Wrong With ColdFusion. The feedback was immediate, and intense, with many people weighing in with their thoughts on what could be done to progress ColdFusion, both as a platform and a language.

Unfortunately, last year I wasn't able to attend the summit, and development of the ColdFusion 11 server was nearly complete, so most of that feedback had zero impact on the new release. While their were many advancements in security and JSON processing, some of the other introductions were seemingly underwhelming, or even unwanted, to many long time CF developers.

Now, to be fair to Adobe, and the ColdFusion product development team, they do have a responsibility to cater to their paying customers. Developers are rarely the ones buying the server itself, and the money handlers buying the server licenses rarely have enough real understanding of the development process to truly provide reasonable feedback when asked "What do we do next?"

Past issues aside, the ColdFusion product team is beginning to explore what they will do with the next version of the ColdFusion server, so now is a good time to begin the discussion again as to what Adobe might do the next time around. It is a delicate balance, so our feedback to the team needs to be positive, constructive, and backed by hard arguments to support our requests.

ColdFusion has been known, since the very beginning, for making the hard things easy, with it's first inroads being in the are of data connectivity. ColdFusion makes it extremely easy to connect with a wide range of datasources. This was probably the first true task of CFML (originally called DBML). It's meeting this type of root level need that ColdFusion might need to focus on going forward.

There were a number of core concepts that came out of last year's discussion:

  • Script Language Overhaul
  • Command Line Interface
  • Package Manager
  • Modular Architecture
  • Support for NoSQL Databases
  • Application Profiling

There are some great suggestions here, and Rupesh actually had included these in his final slide of the cf.Objective keynote presentations as possible items of inclusion in the next version of the ColdFusion server. I, personally, say to Adobe that it is important to review the past year to help define the focus for the future. It is important for the product team to not waste time on solutions that are already available, or that developers can already do themselves with a little study. In that vein, the CLI and Package Manager may not be areas for Adobe to spend time on, since we now have CommandBox available to us. Focusing on solutions that are already freely available to us seems to be a waste of time and resources, unless you intend to go above and beyond any available solution. A key question to ask, in this type of evaluation, is not only "is this already available?" but also "does this truly fit the purpose, enhancement, and growth of our product?"

Modular Architecture

So, what sort of things can Adobe do? Well, the Modular Architecture concept has multiple levels of benefit, not only for developers but for Adobe as well. By creating a "core" build of ColdFusion (db interactivity, includes, custom tags and the like), with "packages" of additional functionality (ORM, CFFORM, CFCLIENT, etc) that could be installed only when required, Abode creates an architecture where developers can customize their environment to the needs of their application. This decreases the overall footprint of the server, removes the "cruft" that might be unnecessary, and expands the licensing options for Adobe as well. I also believe this could significantly improve the cloud options that could be offered for the server as well, which could greatly improve adoption of ColdFusion as a platform.

Image Processing

Image manipulation was a long time coming to ColdFusion, and was a great addition once it finally arrived natively. That said, the current implementation is very process intensive and slow, and support isn't quite what you would expect from a brand like Adobe. It may be time to revisit image processing in ColdFusion, possibly even exploring avenues other than Java for handling these processes, to improve quality and performance.

Server Performance

There is strong evidence pointing to other CFML engines (Railo) as having much better overall server performance. It is difficult to allocate time and resources to something that currently works. But, just because it functions doesn't mean it shouldn't be improved upon. Response time is a critical piece to any application, and Adobe ColdFusion (as a paid and licensed product) should be the best of breed in this category.

Language Overhaul

Again, it's difficult to put time and effort into something that already works. But, the current syntax of script and functions within ColdFusion is a barrier to adoption of the server. This may be one of the biggest, and most asked for, enhancements that Adobe could provide to ColdFusion. Developers, who have traditionally worked in other languages, spend little time evaluating ColdFusion as an option because of the belief that ColdFusion is a second class language. Why would you use ArrayAppend() when every other language uses array.push()? Many objects do provide Java level object access, but many of these are undocumented, or aren't displayed in the documentation as the first line of how something should be done. While ColdFusion must support the current language constructs for some time to come, it really is time to make a more ECMAScript compliant form of script for ColdFusion. Or, at minimum, something much more uniform and familiar.

What Next?

So, with the summit starting later this week, I pose the question again "How can ColdFusion be better?" What would you like to see Adobe focus on for the next version of the ColdFusion server? And why? How? To what purpose? What do you think are areas where Adobe should absolutely steer clear of? It is important that we provide our feedback now, early in this process, and that we do so in a positive and constructive manor.

I will bring any comments given here back to the ColdFusion product team at the summit later this week (yes, I'm presenting this year). I encourage everyone who is going to the summit to voice your opinions directly to the product team as well. I look forward to hearing everyone else's input on this.

Build A Better ColdFusion App: Simple Conditionals

In really large apps, every line of processing can become critical. Every small process can add up, in terms of overall overhead. Especially in high traffic apps. Sometimes, the little things can really make a difference. Even your simple code might be...simpler. Take the following example:

view plain print about
1<cfset mySelections = "1">
2<cfif #mine# eq "0">
3    <cfset mySelections = "0">
4</cfif>

I saw something like this in code this morning. Right off, the first thing you see is that all of the variables are unscoped, forcing the server to do a scopeCheck() to find out which scope each variable is a part of. Then there's the unnecessary bits to go along with it, like setting a variable, then checking another to reset the variable based on a condition. There's also the bit where the one variable is unnecessarily hashed. On top of all of that, variable assignments are one of those things it just makes more sense to write in CFScript. Let's take a look at how this might be improved:

view plain print about
1REQUEST.mySelections = (URL.mine) ? 1 : 0;

One line of code. Less keystrokes. Clearer references, and logic.

The "mySelections" variable, in this instance, is a part of the REQUEST scope (I upper case all variable scopes, to make them easier to spot when editing code).

In this situation, "mine" was a URL variable, param'd further up the page. We've used short-circuit boolean logic in our conditional statement. For those that don't understand that, any numeric value other than "0" is evaluated to true. If the value is "0", then it is false.

And speaking of numeric values, you don't need to quote them. Even though ColdFusion would figure it out, a quoted value is a string. Don't quote numeric, and don't quote Booleans.

We use the URL conditional inside of a ternary operator. Ternary operators were introduced in ColdFusion 9. The basics of this are, if the conditional is true, then use the value after the question mark. If the conditional is false, then use the value after the colon.

Finally, there's no need to hash the URL variable. You only need to hash variable references as part of output, or when they are used inside of quotation marks in code.

Now comes the really fun part. There really isn't any need for REQUEST.mySelections at all. Since the value or URL.mine was param'd, further up in the code, then the variable is always available here. Rather than copying that value to another variable (which takes up more memory), we can just reference URL.mine anywhere that REQUEST.mySelections was being used.

As you maintain your applications, it's always good to take some time and read through what's been written before. Refactoring little nuggets like this one, and a little testing, can eventually go a long way in preserving the life of your app and your server.

Out with 2013, and in with 2014

2013 was Exciting! I had several side contracts, which helped us buy a house. We left Jacksonville, and moved back to the Nashville area. I finally put some health issues behind me, allowing me to get out to some user group meetings again, as well as present. I put in a new topic for cf.Objective, which has been accepted. I picked up the camera I've been waiting a decade to buy, and jumped back in to photography with both feet. And, I carved in some time there to review a few books, do a CF Hour interview, and write a few blog posts (some even a little controversial). Now, there's downside here too. Heavy side contract work is not always conducive to a happy home. Buying a house, much less from another state (and the move that goes along with it) can be very grueling and stressful. Working at this kind of pace can bring on other health issues. The financial requirements of buying a house, moving state to state, setting up a new home, etc, make it impossible to do "other things" (like conferences, for instance). And, I still have several other book reviews I've yet to write, and didn't blog nearly as much as I would've liked. Well, you do what you can with what you have, and pray for the best. The two bright points in all of that are my wife, Teresa, and my daughter, Savannah, who continually support this crazed life, and without whom it really wouldn't be worth doing it all. I can never tell them enough how much I Love Them, nor just how much they mean to me. I never got the opportunity to talk about my conversation with Rakshith, concerning the future of ColdFusion. It was a great conversation, focusing quite a bit on Adobe's commitment to the platform, the strides in the education initiatives, and a focus on giving developers the tools (and language) they need to build better products. I think one of the greatest ColdFusion bits, to come out of this past year, was the creation of Team CF Advance. This group, entirely made up of volunteers, is working to produce Open Source applications and API's in ColdFusion. While it is still getting off the ground, the team has already made some pretty big strides. This is the kind of thing that will help bring ColdFusion back out front. I have high hopes, and high expectations, for what is to come from 2014. I've already committed to taking at least one picture a day, gotten seriously started on losing a few (too many) pounds, have several topics laid out for blog series, and am about to put some spit and polish on that preso I mentioned earlier. And that should be just the beginning. So, to all of my friends, colleagues, co-workers, and family, I wish you all the Happiest and most Prosperous of New Years.

What I'd Like To See Come Out of the ColdFusion Summit

So, the very first Adobe ColdFusion Summit is being held this week in Las Vegas, NV. What started out as a small conference, originally capped to 250 participants, is now nearly twice that size, with people coming from all over the world to attend.

We've had a lot of discussions here recently about What's Wrong With ColdFusion, and things that can be done to fix those perceptions. Ultimately, there's been a lot of positive feedback, some reasonable initial response out of Adobe, and a community that's started talking again.

What I'm hoping for is for that discussion to continue, hard, at the Summit. As much as I would like to be there, due to constraints I am unable to attend. So, I'm hoping that the community will come together to ask some hard questions. What really is being done to address the concerns brought up? How does this change current development practice, timeline, and direction? How soon can we expect to see x, y, or z? When, and how, is marketing of ColdFusion going to change?

It's important that we, the community, use this opportunity to speak to some of the engineers. "Why are we doing this? (in this new version) And not doing that?" We have to tell them what we think, and why, to assist in defining new directions. They're always gathering requirements, and you are the perfect focus group. The suits (management types that buy the licenses) can tell them that it should do this or that, but you (the developer) are the ones who truly know the things that are needed.

I know that I've talked a lot about "Adobe" ColdFusion. I am an Adobe Community Professional, so I have to choose my words carefully sometimes. Ultimately, any positive changes are changes that push innovation, competition, and advancement of the platform. In that vain, the Team CF Advance initiative, to write, support, and contribute to Open Source software solutions written with ColdFusion, is one of the single greatest things to come out of our discussion. (Big kudos to Denny Springle [with a side of Corfield], for pulling this idea back out of the hat and getting it up and running) Any time, and assistance, that anyone can give, is a good thing. While we need people to write code, we also need people that can assist with requirements gathering, documentation, and other things. Of all of the suggestions pushed in these discussions, this is the one that we (the developers) can have the most say and control.

Why I Like, and Use, CFScript

Many, many moons ago, I began a journey to learn web development. Actually it was a re-acquaintance, as I had gotten side tracked for a few years in a poor business partnership, having to catch up on how much things had changed. During that time, HTML had moved for v2 to 4, CSS was the crazy new thing replacing font and center tags, Dynamic HTML was making JavaScript hot again, and the browser wars were making life impossible.

Back then I was on the LA Tech Edu JavaScript mailing list (sadly retired, years ago). This guy named Peter Paul Koch was a major contributor to the list, and just ramping up this little site called QuirksMode. Scripting, though somewhat nightmarish with the browser wars, was actually a lot of fun. My first shopping cart was completely JS based.

I have always pushed for full parity between cfscript and tags, because scripting is more natural to me, in terms of writing programmatic logic. Sure, cfoutput and cfloop make a lot of sense in the middle of html display code, but CFC's don't (typically) contain display code, being data access and model objects.

I have issues with the implementation of CFScript. I find that there are a lot of functions of similar actions with completely different naming conventions, and argument requirements, and more. I think these things need to be addressed. That said, if I have to call the function anyway, I prefer script to tags when it's outside of display. It's a more natural approach, to me. 99 times out of 100 I end up with less lines of code, and find the logic more defined, clear cut, and easier to understand.

It's not for everyone. There are many that just plain hate cfscript, and that's their prerogative. But I will continue to use cfscript, and my examples will show that, because I personally find it a better way to write code. If it's not your preference, that's fine, you're welcome to translate my examples to tags if you need to, but for me this is how I do it. (For the record, many of the newer functions are not identical, under the hood [base Java code], as their tag counterparts, and some scripted functions have been proven to have better performance than their tag counterparts. There are benchmarks for this out there, somewhere, if you feel strongly enough to go look for them. I just take it on my experience with using it.)

Are You Running ColdFusion on a Mac?

Yes, Apple is a fantastic company, making really nice products that work very well. If someone gave me one of those nice Macs with the 27" screens today, I'd probably switch. I wouldn't buy one myself. Nice as they are, I can't justify the expense when I can buy a machine twice as powerful for half the money, and actually repair it myself when I need to. But, that's my decision. I choose the imperfections of Windows on a PC architecture as a counter to the affordability and maintainability of the platform. And, it's done really well by me.

I watched Andy Matthews accidentally spill orange juice on to Aaron West's 17" MacBook Pro once, several years ago. Aaron finally got it back from the Mac Store about two weeks later. I can't afford that kind of productivity loss. No thanks.

Again, this is just me. Many others still use a Mac, and love it, and I get it. It's a fantastic operating system, and Apple does make pretty stuff.

But I wouldn't load ColdFusion server on a Mac. Not really. Not on to OS X directly. Yet, I've heard this complaint recently. About how buggy the ColdFusion install is, and what a hassle it is to get up and running.

You're running it on a Mac? On OS X? Why?

The web doesn't run on a Mac. Yes, there are OS X servers, but have you seen that market share? The web runs on *nix and Windows. And, if you're writing code for the web, then your environment needs to match. Load up a VM, and install ColdFusion on the VM, in *nix or Windows. That makes sense.

Is that where you're having trouble? I get CF up in about 20 min on my Windows Server VM, and that includes the download time.

Now, should the ColdFusion server install easily on a Mac? Sure, I think it should. There are way too many developers out there trying to do exactly what I've described, and they're in pain. Go badger the Adobe CF team to get it straight.

But, again, what's your site running on?

You can post comments if you like, but I'm not taking the bait.

What's Wrong With ColdFusion? Round 1 Response

Last week I raised the question, and Wow! Have people responded? Yes. There's some fire in the belly, and a lot of people have a lot of opinions. More importantly, they have a lot of great ideas as well. So, what I'd like to do here for a minute is break down all of that feedback, to get down to the meat. We've attracted some attention, with our little discussion, so I think it's important to focus on all of the core points. From there? Good question. People are listening. Maybe we help to blaze a new trail in the wilderness.

Make It Better

First and foremost, there was an overwhelming call to "get with the times". Among complaints about stability, setup, and pricing, the key take away was that the server needs some retooling. Smarter people than me have talked about the pitfalls of CF running as a servlet, issues with context roots, and (continuing) issues with object instantiation, and all of these things should be addressed. Take that feedback and couple it with the two largest suggestions in the bunch: Modular feature deployment/package bundling and management, and a Command Line Interface (for multiple reasons).

A modular approach can absolutely open a lot of doors, both for developers and Adobe. It can allow someone to deploy a server with only what they require for their application, or upgrade that server's capabilities as required as well. These cut out the cruft, allow the system to be smaller/faster/better, and possibly provides a new (and ultimately more profitable) way for Adobe to handle the licensing of their product. Strip 'er down to her core, then provide deployment packages for things like cfform, orm, office and exchange integration, etc. This modularity also would allow Adobe to laser focus on updates to key areas in a more timely fashion as well (like bringing SharePoint or Exchange support up to the current version in a productive way, etc).

As a broader part of that picture, many asked for the removal of features (UI cruft, cfform, all tags, etc). This isn't really practical, considering the thousands of applications running and supported on ColdFusion today. Adobe needs that licensing revenue. That said, the revenue goes away if they (insert business names here) start switching languages. This modular approach opens new licensing models, better tailored to larger business (and developer) needs, and can address key concerns on the cost of scale. The comparison to the current cloud offerings are a prime example of how this model could truly be a more effective tool for everyone.

The next major suggestions all revolved around core language improvements. The tag model does have it's place, especially with the templating aspects of ColdFusion (generating output), but CFScript, and associated core "functions", require some overhaul. There's a lot of inconsistency in naming conventions, argument order and treatment, lack of member functions, core output, etc., and there's some serious call to correct that. CFScript should be more ECMAScript compliant, and Adobe already has serious experience with this with their development of ActionScript. How they do all of that, and maintain backwards compatibility at the same time, is a question for folks smarter than me, but it absolutely makes sense. Working in ColdFusion should feel native to anyone who writes HTML, CSS, and JavaScript for a living, and right now it's a little off the rails there, especially when it comes to script.

True Issues To Address

Aside from the suggested improvements, there was a lot of conversation about things that truly are broken, and require attention. I'm not just talking about the list of bugs in the bugbase, but some core process issues. Adobe ColdFusion is a paid product, and that licensing includes "enterprise" support. As such, a common complaint is that the support is unknowing, uncaring, or unresponsive. When I call in for support on install issues with Creative Cloud, I was able to get quick and solid resolution, and follow-up. Why should ColdFusion be any different? And why, when a true issue is brought up (like some of the recent security issues), should it take weeks and months to admit the problem, allocate resources, and write/test/deploy fixes?

I, and everyone else, understand that ColdFusion server development is a closed ecosystem, being that it is a corporate product. It does not have the benefit of rapid development that an Open Source project might have, with a large community behind it. That said, considering the costs involved in licensing the product, the turnaround model on identified issues actually ranks a higher priority. How you interact and respond to your customers is critical. This is just business sense, as the customer you keep happy is the one that you retain and keeps buying your product (and tells others how awesome it is).

The other addressable issue, brought up in the conversation, is marketing and education. ColdFusion isn't being taught (or it is, but very little), and new developers aren't coming in to the fold. Some of this is marketing, some of this is perception, and some of this is ... Well, what is it? Why isn't every high school and college in America (or the world) given licensing for ColdFusion? Not ed licensing to dev on, but actually running their university sites, and student unions and such? Why aren't there coding challenges being sponsored in classrooms, to help create the next round of rockstar open source applications? And why aren't there timely, up-to-date, curriculums being developed for these markets? Materials that help teach the language, with focus not only on the language and the server but also development as a whole and best practice?

OK, so all of these "issues" require resources, in an age when things have been scaling down. We've identified them as issues. We've identified their importance. Now it's up to someone to decide the value of addressing those issues.

Where's Our Community?

ColdFusion has, for me, always been a great community. There are hundreds of developers out there who have worked at this stuff for a long time, tripped over good code and bad, and attempted to provide their own brand of support through blogging and answering StackOverflow questions, and just sharing in general. They've done these things, usually, on their own time, with their own money, and at the sacrifice of other things.

But, it's easy to fall off that wagon when you're trying to help others and someone else just tells you "you're doing it wrong". A great case in point here is the OO debate: should you or shouldn't you. First, I'll say "yes, you should", for a thousand little reasons, but then I'll also say "you don't have to, but you should." Second, I'll say that there's no one way to approach development, and that each approach provides it's own pluses and minuses. The single greatest thing that you can do, as a developer, is to read other peoples' code, and realize that it might not be the best approach, or that it might be a much better approach. Each of us has something to learn from someone else, as each of us has a different perspective. Yes, sometimes that perspective may be wrong, and it's good for us as a community to police one another, in our examples, to help promote better code. It's how we have those conversations that will change us. "This Sucks," is not a productive response. Sure, I hate getting called out on my crap code, and then I learn from it (thanks Ray ;) ) [For the record, go read the code for FW/1. Outstanding! The things I learn from Sean...]

The other side to that coin is the framework debate. We have a lot of "mine's bigger than yours" going on, still. The thing is, these are tools, each of them written differently and from different points of view, and if all of these framework developers were to collaborate, instead of pulling out the yard stick, we could really move mountains. You people are smart, and you're dedicated, and you have great ideas. Please work with each other instead of against one another.

And this comes down to the final area of discussion, in round 1, and that's our community's willingness to share their work. There are many people out there that write thousands upon thousands of lines of fantastic code that never sees the light of day outside of a firewall. One great comment I saw said something like "What if every CF project were out there and you could just drop it in and it almost worked?" How many user management modules have you written? Permissions systems? Rudimentary document management? Can't you put anything on GitHub? RIAForge? Every small bit of code we contribute, as a community, adds to the overall ecosystem. We have to start helping each other solve common problems. These other communities, that so many developers are turning to? That's what they've been doing right. And that's where we, as a community, have been failing. There were a lot of fingers pointed toward Adobe, in the comments to my post, but I'll remind you that every pointing hand has three fingers pointed back. We have brought a good bit of this upon ourselves as well, and only we can change that.

I, for one, do not think the battle is over. I, for one, still think there's a life for ColdFusion and ColdFusion development. Yesterday Matt Gifford and Scott Stroz and I sat down for the CFHour podcast, and Scott said "If JavaScript can have such a resurgence, then why can't ColdFusion?" And he's right.

So, this recaps (very high level) all of the comments on my last post. The discussion has begun, now where do we take it? Can we define a path for ColdFusion's future? Is Adobe part of that discussion? (I hope that they are) I would like to hear from you again, dear reader. What are your thoughts on what's being said today? Throw out the negative, focus on solutions, and tell me what you believe can/could/should be done for us, as a community, to move forward and thrive.

What's Wrong With ColdFusion?

So, today there was a little discussion on Twitter about ColdFusion. ColdFusion lives on top of Java, specifically on top of the JVM, which makes it capable of processing other languages as well. Sean Corfield has put out some things in the past on this. I mentioned that it would be good to rekindle talk of how that is possible, in ways to help promote ColdFusion as a platform.

I was somewhat surprised by Sean's response.

#coldfusion really has no value to those communities - they already have better languages and better tools

Now, I want to go on record now as saying that I love Sean to death, and really and truly respect his work and his opinions. I also love ColdFusion a lot too. So, my question (basically) then became "What's wrong with ColdFusion?"

So, I posed another question to Sean, that I'll pose to the community as a whole: What's wrong with ColdFusion as a language? As a platform for enterprise development? More to the point, how can it be made better?

I'm not looking for a hack fest, or "my crap is better than your crap" stuff, I'm looking for some solid feedback. What does it take to try to make ColdFusion a first class choice among programmers of web enabled applications? More to the point, what does it take to do that and keep it CF simple? ColdFusion has always been a great Rapid Application Development platform, with a very lower barrier of entry, and an ease to learn and maintain. Is it too simple? Too forgiving?

If the direction of the ColdFusion platform development were to drastically change today, with a focus on the language and the core of the system, what would/should that look like? What is truly missing? What should be done differently, and how? (And why?) Gimme the nuts and bolts.

The floodgates are open now. If we never talk about it, nothing will ever change. Please be constructive, and let me know your thoughts.

Legacy Code Part 17: The Rest of The Story

As developers, sometimes it is hard to see beyond the code. We know code. We like code. Some of us occasionally even dream in code (just ask my wife...) Knowing this, it is sometimes difficult, when troubleshooting performance of Legacy Code, to remember that the issue might not be in code.

One great area, that so many developers overlook, is the ColdFusion server itself. The installer makes it fairly easy to get things up and running, but is the environment truly setup optimally for your application? By default, CF only loads allocating 512kb of RAM to the underlying JVM. 512kb is not much, especially in a high traffic, heavy process system. And have you ever adjusted your Request Tuning settings? Checked your Queue Timeout? What sort of template caching are you using?

Another area to look at is your JVM itself. While you can adjust some of the JVM settings in the CFIDE (in ColdFusion 10) properly, it's still a good idea to review things like your Garbage Collection settings, your RAM allocation, and other bits. Are you loading unnecessary libraries? And, are you still using the installed version of the JVM? It might be worth while to download a new JDK, install, and test your app. For one thing, it'll help keep your underlying Tomcat more secure.

Then there's the hardware and network review. What sort of throughput are you getting from your hard drives? Is your file I/O optimal for the ops you're running? Are you storing data and assets on other network connected systems and, if so, what sort of throughput are you getting from those internal connections.

And then we're back to your database. Hopefully it isn't on the same machine, but the same sort of review applies. Do you have enough RAM? What sort of hard drives are you using? Are you getting enough throughput through that old NIC card?

Some of these things are really easy to address, taking a little time and effort and research. Others may require parts and equipment replacement, maintenance windows and downtime. It's really up to you to balance out what makes sense.

Step one: write a plan.

Step two: follow through.

With these last 17 posts I've written down a lot of little things to help anyone take their Legacy Code (outdated and tired ColdFusion applications) and begin to carry them forward into new life. Some changes are farther reaching than others, and all require careful research, planning, management and testing. To let these applications sit, without thought for modern change, is to waste the time originally spent to create them in the first place. Nothing grows without care and feeding and light.

It is my belief that you can still benefit from the hundreds of thousands man hours of previous time and effort spent on these applications, without having to take drastic moves that could prove unnecessary or even disastrous. ColdFusion was the first web application server, outliving many predecessors, and continues to grow with the times. ColdFusion continues to be a fantastic Rapid Application Development platform, allowing many developers to write applications in a fraction of the time it would take on other platforms, and there's a solid roadmap for future versions already on the board. There are thousands upon thousands of active, thriving, scalable and performant ColdFusion based applications on servers in thousands of top ranking companies in countries all around the world, still, to this day, because of the power available here.

This article is the seventeenth in a series of articles on bringing life back to your legacy ColdFusion applications. Follow along in the Legacy Code category.

Legacy Code Part 16: How You Get Data

One of the greatest culprits in poorly performing ColdFusion applications, Legacy Code or modern, is badly written SQL. ColdFusion was originally written as a middle tier between the web server and the database, giving us the ability to output queried data in html format. In fact CFML was originally DBML. One of it's greatest strengths has always been the ease with which one could get data back from a multitude of datasources, from a variety of platforms, and display it to a user. One of it's greatest weaknesses is that it allows you, the developer, to write those queries just as poorly as you want to as well.

How many queries in your system start with SELECT *? Of the 35 columns in that table, are you really using more than five or ten? And, do you have multiple <cfquery> calls, one after another, with each using data from the query before? Can this be translated into a single query using some well thought out joins? By the way, when's the last time you analyzed your query performances? How about rebuilt your table indexes?

In most applications that I've worked on, Legacy and modern, major bottlenecks occurred due to the poor performance of queries. Applying <cfqueryparam>s helped a little, but truly reviewing each query, running it through a query analyzer, rebuilding and creating new indexes.

Some people, especially writing quick small apps and prototypes, have used ORM frameworks for their database interaction, such as Reactor, Transfer, and now ColdFusion's own built-in implementation of Hibernate via ColdFusion ORM. These are very popular, and great for quickly standing up new product, but they are also very object intensive, and don't necessarily give you deep introspection into what those data transactions are truly doing under the covers. Yes, they can allow you to quickly build new applications, but that doesn't necessarily mean that those applications will scale well, or continue to perform three years later the same way they did on day one.

There was a really good article by Chris Travers on DZone, a few weeks back, defending the choice to continue to hand code your SQL. It's not a very long article, but one paragraph really stood out for me, and is something that I already do.

I find that my overall development time is not slowed down by hand-writing SQL. This remains true even as the software matures. The time-savings of automatic query tools is traded for the fact that one doesn't get to spend time thinking about how to best utilize queries in the application. The fact is that, as application developers, we tend to do a lot in application code that could be done better as part of a query. Sitting down and thinking about how the queries fit into the application is one of the single most productive exercises one can do.

This is something that is very easy for me to identify with, and also a good argument for the (occasional and well thought out) use of stored procedures. Many developers stay away from stored procedures because a) they don't know how to write or use them, and/or b) those procedures aren't stored in code, so it's not as easy to introspect or search for things when you're making changes. While both of these may be valid arguments, in some way, there is the performance trade off. Stored procedures due, typically, perform better, having compiled cached execution plans on the SQL server. If you can overcome your other obstacles (and you can), you can gain from placing complex SQL logic inside of stored procs.

Again, this type of change, in a large Legacy Code system, can be long and arduous. Set a goal, with each bit of maintenance that you do, to review the queries you are using in the requests you are adjusting. Tools like FusionReactor can help you identify slow running queries, for you to target your efforts. It may pay well to hire an outside SQL resource to review your databases, monitor query performance, and provide detailed analysis and suggestions on improvement. A good DBA, even a part timer, can save a Legacy Code application from extinction.

In our next post we'll dive into some of the things that you can do at the Application Server level, to help you get the most out of your Legacy Code.

This article is the sixteenth in a series of articles on bringing life back to your legacy ColdFusion applications. Follow along in the Legacy Code category.

More Entries