April 13, 2018
Easily Moving from Legacy Code Hell to Modern CFML Heaven
April 13, 2018
Easily Moving from Legacy Code Hell to Modern CFML Heaven
Host CF Alive podcast, founder CFUnited, CEO TeraTech
Wizard 49 posts
Followers: 15 people

We’ve all seen the hell of old legacy code in our ColdFusion applications. Non-framework code, spaghetti code, duplicate code, or unused code (Deadwood)… it’s all the same. Maintenance efficiency is a thing of the past and code usefulness is gone.

How do you move from that legacy hell to a heaven of modern CFML with easier maintenance and deployment, fewer bugs, and streamlined code?

Fear not! There is a way, and it’s easier than you think.

What is Legacy ColdFusion and Why is it Hell?

Legacy ColdFusion is code developed years ago in an old style of CFML. Sadly, many applications still run on this ancient framework.

Often this code is “spaghetti code” or an unstructured and duplicated mess. There can also be quite a bit of unused code –deadwood- that makes it harder to change or update because you don’t know what code is being used.

It is hell if you experience bugs. It’s usually a very hard process to go about fixing them and can be very expensive. It’s like a game of Whack-a-Mole; once you fix one bug, two more pop up somewhere else.

Why Do Most Projects Using Legacy Code Fail?

Imagine you are on a team of developers working on a huge legacy application. There is a security bug somewhere in the code. The future of the company relies on your team’s ability to find and fix these bugs and ensure they don’t pop up again.

Now imagine going through thousands of lines of unused or duplicated code. With the clock ticking, you may be lucky to find the bug until more bugs pop up somewhere else.

A nightmare, right? What is the Answer?

Why Move to Modern CFML

Most of us understand that moving our legacy applications to modern CFML is smart and well worth the resources you spend doing it. To those still holding back, here are a few reasons why modern CFML is heaven compared to legacy.

  1. Easier Maintenance – Simple and clean code structures help make everyday tasks a breeze.
  2. Rapid Deployment – Everyone wants to deploy changes and make future requirement changes to your application quickly and easily. When your code is solid, nothing is keeping you from making quick work of your tasks.
  3. Fewer Bugs – Finding and fixing bugs will be much easier. You’ll think you found your virtual can of insect spray!
  4. Modern, Responsive Front-End- It works on both mobile and desktop browsers seamlessly.

When starting a new project, most ColdFusion development teams follow the rule of the Iron Triangle (or project management triangle). According to the article by Robert Swisher, “Fast, Good or Cheap. Pick Three?” on business.com, by introducing the concept of “Lean” (or The Lean Startup Method, by Eric Ries), it is possible to have all three in your applications.

How to Move from Legacy Code to Modern CFML

We’ve talked about the why, but what about the how? How do I move my legacy code to modern CFML? There are a number of clear-cut steps in the process, so let’s begin with the first:

Refactor Real-World Procedural Code into MVC-Style Code

Code refactoring is improving the internal structure of the code while preserving its external behavior.

  • Decide what code belongs in the Model, the View, and how the Controller ties the two together.
  • Cut down the size of files by pulling parts out of the giant file and put in include files
  • Move out the SQL and ColdFusion logic
  • Dedup (deduplicate) similar code
  • Move out the front-end code to View include files
  • Start running with the remaining code in the View

Strategies for Migrating Large ColdFusion Applications in Phases

When you have a large Adobe ColdFusion application, everything seems like an entirely different ballgame. It can seem like a daunting task, until you break it down:

  1. Use the ColdBox legacy tool feature, as discussed in the ColdFusion Alive Podcast #059, “Migrating legacy CFML to MVC (Model View Controller) with Nolan Erck.”
  2. Use Version control such as Git.
    1. Utilize 2 branches: Legacy and MVC
    2. Maintain both
    3. AB test each branch

Nolan Erck brings up another point in the ColdFusion Alive Podcast #059, “Migrating legacy CFML to MVC (Model View Controller).” Whatever decisions you make about your project, make sure you don’t continue incurring technical debt. Make the right decisions up front and take the time to do things right, and you won’t have built-up trouble later in the life of the application.

Other things to consider when taking up the project to move your code from legacy ColdFusion to modern CFML are:

  • Efficient workflow – Maintaining an efficient workflow in both your development and the design of the ColdFusion application will ensure that your app will be easy to maintain and update.
  • Use version control – Using version control should be a given. Remember, the feeling of knowing your code is safe is priceless. 

The Single Most Important Thing to Remember in Changing to Modern CFML Heaven

The most important thing you can do is to use best practices. This concept is explained best in the ColdFusion Alive Podcast #047, “Best Practices Are Best, Except When They’re Not with Nolan Erck.”

In the podcast, Nolan talks about many of the things covered in this article, including technical debt, but he also says this about best practices:

“…best practice is a technique or a guideline of some kind that has generally been accepted by whatever community you are part of. In this case, ColdFusion or CFML, as that’s the at least currently less proper respected way to do whatever the task is you’re talking about. The reason I say most current is sometimes; best practices are all over in the course of the evolution of the language, or evolution of the technology stack, or whatever. So, it might be a best practice today, may not have been a best practice five years ago. And it might not be a best practice five years in the future.”

Adhere to best practices, but realize they will change with time and innovation.

Conclusion – CFML Nirvana?

The benefits you will receive in ease of maintenance and deployment along with fewer bugs will be refreshing. You will wonder why you didn’t make the change long ago!

Don’t be worried about the money you have to invest. The money you save in the long run will more than make up for the little you spend upgrading your applications.


And to continue learning how to make your ColdFusion apps more modern and alive, I encourage you to download our free ColdFusion Alive Best Practices Checklist.

Because… If you are responsible for a mission critical or revenue-generating CF application that you don’t trust 100%, where implementing new features is a painful ad-hoc process with slow turnaround even for simple requests, you have no contingency plan for a sudden developer departure or a server outage, where every time a new freelancer works on your site, something breaks and application availability, security and reliability are poor.

And you are depending on ColdFusion for your job,  then you can’t afford to let your CF development methods die on the vine.

You’re making a high-stakes bet that everything is going to be ok using the same old app creation ways in that one language  — forever.

All it would take is for your fellow CF developer to quit, get run over by a bus or your CIO decides to leave the (falsely) perceived sinking ship of CFML and you could lose everything—your project, your hard-won CF skills, and possibly even your job.

Luckily, there are a number of simple, logical steps you can take now to protect yourself from these obvious risks:

No Brainer ColdFusion Best Practices to Ensure You Thrive No Matter What Happens Next

ColdFusion Alive Best Practices Checklist

Modern ColdFusion development best practices that reduce stress, inefficiency, project lifecycle costs while simultaneously increasing project velocity and innovation.

  •  Easily create  A Consistent Server Architecture Across Development, Testing, and Live
  •  A Modern Test Environment to prevent bugs from spreading
  •  Automated Continuous Integration tools that work well with CF
  •  A Portable Development Environment Baked into Your Codebase… for free

Learn about these and many more strategies in our free ColdFusion Alive Best Practices Checklist.

Add Comment