Nolan Erck talks about “Migrating legacy CFML to MVC (Model View Controller)” in this episode of the CF Alive Podcast, with host Michaela Light.
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
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
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
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