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
Show notes
- 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
Listen to the Audio
Bio
Nolan Erck
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,
Read more
Michaela Light is the host of the CF Alive Podcast and has interviewed more than 100 ColdFusion experts. In each interview, she asks "What Would It Take to make CF more alive this year?" The answers still inspire her to continue to write and interview new speakers.
Michaela has been programming in ColdFusion for more than 20 years. She founded TeraTech in 1989. The company specializes in ColdFusion application development, security and optimization. She has also founded the CFUnited Conference and runs the annual State of the CF Union Survey.