ColdFusion: Are there any use cases for Application.cfm for Application.cfc

I am modernizing a large legacy ColdFusion application that heavily uses Application.cfm template files instead of the new Application.cfc files.

Application.cfc seems to offer a more efficient solution for everything that the Application.cfm file can do.

  • Application.cfm runs each line sequentially for each request, so it will recreate the application variables with each subsequent new page request. (May lead to performance loss if many downloaded applications) The Application.cfc allows some truly global variables to be avoided by using the onApplicationStart() and onRequestStart() methods

Does anyone come across any use cases / examples (besides the obvious time it takes for the port) where Application.cfm pages are preferable to Application.cfc

+5
source share
1 answer

IMO, this is not a "too broad" topic. This is not an opinion, I would call it best practice.

There are many reasons to use cfc for cfm . I was in this particular situation.

Here is a list of common functions available in Application.cfc (I'm sure you know):

  • onApplicationStart ()
  • onSessionStart ()
  • onRequestStart ()
  • onRequest ()
  • onRequestEnd ()
  • onSessionEnd ()
  • onApplicationEnd ()
  • OnError ()

Without going into the details of each of them, having the ability to sort your code in context buckets like this, you can better manage your various areas of variables. Without these contextual triggers, you simply respond to the procedural aspects of Application.cfm .

While both users are launched on each page request, only certain functions in cfc . cfm , you have code running all the time, checking the conditions for when it should or should not run.

Staying with cfm , of course, less risky, but if you cfm it, you should expect that you will damage things along the way. The adoption of best practices should be part of this process.

+7
source

Source: https://habr.com/ru/post/1273590/


All Articles