Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ITB2015 - Migrating legacy applications to ColdBox MVC

483 views

Published on

Have you fallen in love with Coldbox but spend your days wrestling with that old legacy application? It can be refactored into Coldbox, and it's not as hard as you think. We'll discuss the practical, step-by-step process to bring a legacy application into Coldbox based on real experience. We'll highlight the considerations and potential hangups so you're empowered to bring your app into the modern world.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

ITB2015 - Migrating legacy applications to ColdBox MVC

  1. 1. ColdBox <3 Legacy App IMPLICIT VIEW DISPATCH WRAPS YOUR APP IN COLDBOX
  2. 2. Your Host ‣ Scott Coldwell ‣ Developer at Computer Know How ‣ Houston, TX ‣ CF dev since 2006 ‣ @scottcoldwell
  3. 3. ‣ Define Implicit View Dispatch ‣ Practical steps to port your legacy app ‣ A vision for moving forward after porting What We’ll Learn
  4. 4. Implicating a dispatched view…huh? ‣ In ColdBox, if a view file exists, it can be called without a handler ‣ The handler/event are implicitly created ‣ The view doesn’t need to know anything about ColdBox ‣ You could write an entire app with only views
  5. 5. ‣ If you could write an entire app with only views, you can drop an existing application into the views directory, and it would run*! ‣ * slight modifications may be necessary‡ ‣ ‡ … are almost definitely necessary ‣ Good news: fairly straightforward Drop in that legacy app!
  6. 6. ‣ Make URLs compatible (index.cfm) ‣ Deal with Application.cfc/cfm ‣ Routes ‣ cfincludes, createObject, etc Overview of Must-Dos
  7. 7. ‣ Primary concern: index.cfm in ColdBox URLs ‣ ColdBox has URLs like this out of the box: ‣ http://myapp.com/index.cfm/user/account ‣ But your app probably had a URL such as: ‣ http://myapp.com/user/account.cfm ‣ NOTE: the .cfm extension is no longer necessary, but IS permitted ‣ To fix: Enable SES URL setting in CB; web server rewrite rules (see docs) Must Do: URL Compatibility
  8. 8. ‣ Coldbox is now the Application. ‣ Settings, environment variables, and other magic must find a new home ‣ May I recommend ColdBox settings and environments? ‣ Datasources, mappings, etc can be moved to ColdBox’s Application.cfc Must Do: Application.cfm/cfc
  9. 9. ‣ ColdBox auto-generates (implicitly dispatches) handlers and routes for most cases ‣ You need custom routes for 2+ deep directories ‣ addRoute(pattern="/ajax/tags/:action", handler="ajax/tags"); ‣ Use CLI tools to get a list for you ‣ find with mindepth option Must Do: Routes
  10. 10. ‣ Prepend all <cfinclude> template values with /?views/ ‣ - <cfinclude template=“/widgets/top_nav.cfm”> ‣ + <cfinclude template=“/views/widgets/top_nav.cfm”> ‣ - myObj = createObject(“component”,”cfc.myCoolObject”); ‣ + myObj = createObject(“component”,”views.cfc.myCoolObject”); Must Dos: cfincludes, createObject, etc
  11. 11. ‣ CFC invocation: createobject ()-> getModel() ‣ WireBox ‣ Move settings and environmental settings to ColdBox.cfc ‣ Utilize Layouts ‣ Assign layouts to views in ColdBox.cfc ‣ empty layout Overview of Should-Dos
  12. 12. ‣ Use getModel() instead of CreateObject() ‣ easy search/replace ‣ Use WireBox inside of model objects ‣ + <cfproperty name="myOldCFC" inject=“model:myOldCFC"> ‣ - <cfset foobar = createObject("component","myOldCFC").doSomethingAwesome() /> ‣ + <cfset foobar = myOldCFC.doSomethingAwesome() /> ‣ Consider how to handle the init() call, if applicable Should Do: CFC invocation
  13. 13. ‣ ColdBox has great settings management ‣ ColdBox has great environment management ‣ Use them ‣ Search/replace ‣ - application.mySpecialSetting ‣ + getSetting(“mySpecialSetting”) Should Do: Settings, environments
  14. 14. Should Do: Layouts ‣ See if it makes sense for your app ‣ Control multiple layouts via Coldbox.cfc ‣ Special cases ‣ Blank layout for ajax responses
  15. 15. ‣ Move static assets to /includes ‣ Move CFCs to /models ‣ Utilize Security interceptor ‣ Configure WireBox for models ‣ Use RC scope instead of form/url Overview of Could-Dos
  16. 16. ‣ New development can be ColdBoxy ‣ Refactor legacy code to be MVC using models, handlers, and views ‣ Tighter integration with ColdBox offerings: (e.g. LogBox, ForgeBox items, etc) Going forward
  17. 17. ‣ Lay as much groundwork as you can, but get it out the door ‣ Search and replace (with regex) is your friend! ‣ Use a build process, not just source control ‣ Don’t take on too much at once! Port the app, then refactor Final Notes
  18. 18. ColdBox all the things

×