Nolan Erck talks about “Migrating legacy CFML to MVC (Model View Controller)” in this episode of the CF Alive Podcast, with host Michaela Light.
Contents
Episode highlights
- What exactly is legacy ColdFusion?
- A broad term
- Non-framework code
- Might use CFIncludes or some CFCs to be modular
- Even giant 10k lines of code
- Self-posting forms
- What the MVC design pattern is and what problems it solves
- MVC = Model View Controller
- Model = biz logic and SQL
- View = front end UI – HTML, CSS, JS
- Controller = the glue that holds the Model and View together and says which part calls which
- Customer in a restaurant ordering from a Menu (View) from a Waiter (Controller) to make the food in the kitchen (Model)
- Maintenance easier
- Whack a mole bugs
- Biz logic, HTML, JS and SQL all mixed up together
- Bit rot/Technical debt
- Hard for designers to edit the code as the HTML is mixed up
- Merge conflicts
- Hard to fully test
- Manually testing
- Duplicate code, unused code (deadwood)
- Specialization of labor
- UI experts
- CF developer
- SQL database engineer
- MVC = Model View Controller
- How the FW/1 and ColdBox frameworks use a convention-based approach to bring consistent structure to an application
- Both are modern MVC
- Use folder to separate the three parts, file naming conventions
- FW/1 is minimalist, one file, easy to get started
- MuraCMS uses it
- ColdBox is heavyweight with more features and add-on packs in the Box ecosphere
- Testing
- Caching
- Etc
- Ortus supports
- Other MVC frameworks that are not as maintained
- CFWheels – These are convention based frameworks
- Fusebox – XML config file framework
- Mode Glue – XML config file framework
- Mach-ii – These are convention based frameworks
- What Dependency Injection (DI) is, how it simplifies the “model” portion of applications, and how they are used in FW/1 and ColdBox
- Keeps your objects organized
- Tools
- DI/1
- Wirebox
- We did a whole interview on this topic in another episode of CF Alive
- DRY = Don’t Repeat Yourself
- DI and MVC are independent
- How to refactor real-world procedural code into MVC-style code
- What code belongs in the model, the view, and how the controller ties the two together.
- Cut parts out of giant file to include files
- Move out the SQL and CF logic
- Dedup 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 applications in phases.
- ColdBox legacy tool feature
- Version code such as Git
- 2 branches
- Legacy
- MVC
- Maintain both
- AB test each branch
- 2 branches
- All URLs will change
- Using CommandBox and Git to spin up on-demand instances of ColdFusion and manage our code.
- CommandBox
- command line CF
- Instant server setup or config
- Any version, Adobe ColdFusion, Railo, Lucee CFML
- CommandBox
- Tool costs
- FW/1 free
- ColdBox free, pay or training and support
- CommandBox – free
- Git free to paid
- Source Tree – free
- Sublime Text – free to shareware paid $35
- CF Builder free 30-day trial, $300
- Why are you proud to use CF?
- WWIT for you to make CF more alive this year?
- What did you enjoy at CF Summit?
Nolan’s CF Summit workshop description
Do you maintain legacy ColdFusion applications, perhaps written with old procedural-style code? Have you been told you should be using a Model-View-Controller (MVC) framework but don't really understand how that works? Does the idea of rewriting the entire application seem like an impossible task? What if you could instead revamp your code in phases, without having to do it all at once?
Come to this workshop and learn:
- What the MVC design pattern is and what problems it solves
- How the FW/1 and ColdBox frameworks use a convention-based approach to bring consistent structure to an application
- What Dependency Injection (DI) is, how it simplifies the “model” portion of applications, and how they are used in FW/1 and ColdBox
- How to refactor real-world procedural code into MVC-style code
Hands-on portion of the workshop will:
- Analyze and deconstruct a simple procedural application to see what code belongs in the model, the view, and how the controller ties the two together.
- Move the code into the appropriate MVC layers and test it.
- Discuss strategies for migrating large applications in phases.
- Use CommandBox and Git to spin up on-demand instances of ColdFusion and manage our code.
This workshop will help anyone with a moderate skill level in ColdFusion, and at least some familiarity with object-oriented programming concepts. It will be a Bring-Your-Own-Laptop session. Prior to the CF Summit we will provide links and instructions to download and install CommandBox and the sample application code.
Mentioned in this episode
- MVC
- FW/1
- ColdBox
- Dependency Injection, why is it awesome and why should I care? with Nolan Erck
- Kishore CF Summit East episode
- Adobe CF Summit (Las Vegas)
- OrtusSolutions
- BlueRiver
- DI/1
- Wirebox
- CommandBox
- Git episode
- Sublime Text
- CF Builder
- Convective CF tuning guide
- Bring Order to the Chaos: Take the MVC Plunge
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… perhaps 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.
What if you have no contingency plan for a sudden developer departure or a server outage? Perhaps every time a new freelancer works on your site, something breaks. Or your application availability, security, and reliability are poor.
And if 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 or for your CIO to decide 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 production
√ 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.
Podcast: Play in new window | Download | Embed
Subscribe: Apple Podcasts | RSS
Bio
Nolan Erck has been developing software for 19 years. Starting in the video game industry working on titles for Maxis and LucasArts, then advancing to web development in 1999, his list of credits includes Grim Fandango, StarWars Rogue Squadron, SimPark, SimSafari as well as high-traffic websites for clients. Nolan manages the SacInteractive User Group, teaches classes on aspects of software development, and regularly gives presentations at conferences and user groups across the country. He is also Chief consultant at South of Shasta.
Interview transcript
Michaela Light 0:01
Welcome back to the show. And today we're going to be looking at migrating legacy cold fusion code to MBC. That's model view controller for those of you haven't come across it yet have been around for quite a while. And we'll look in the episode with Nolan arc, who is the chief genius at south of Sastre
does a lot of ColdFusion. And he's been doing software development for like 19 or 20 years now.
And we'll look at what MBC is, and what problem it solves. And in particular, we'll dig down into framework one and code box, which are two frameworks which use MBC. And we'll also look at dependency injection and why you should be using that in your MBC apps, and how you can use it in framework one and code box and how you can refactor your real world procedural code. I think that procedural code maybe as a special way of saying it might be a little like spaghetti but maybe not. Maybe
Your code is better.
And we'll look at some strategies for migrating large apps
over to MPC in phases, so you don't have to freak out with this. And if we get time, we'll also mentioned CommandBox and get and how they could help you out do this faster. So welcome, Nolan.
Nolan Erck 1:18
Thank you. Thanks for having me.
Michaela Light 1:19
Yeah. So I know you did a whole day workshop on this at CF Summit out in Las Vegas. And you had hordes of developers learning how to do it, or a horde is about 40 people, I think,
Nolan Erck 1:34
yeah, we had, I think there were about 40 students in the class.
Michaela Light 1:38
That's great. So what exactly is legacy ColdFusion because that term gets thrown around a lot.
Nolan Erck 1:47
It does. And that's a that's a pretty broad, maybe ambiguous term. My opinion is, it's 2018. Pretty much any ColdFusion code that is not really
In a proper framework ColdBox, framework one,