ColdFusion:在任何用例中,Application.cfm比Application.cfc更可取 [英] ColdFusion: Are there any use cases where an Application.cfm is preferable to an Application.cfc

查看:92
本文介绍了ColdFusion:在任何用例中,Application.cfm比Application.cfc更可取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在升级大型旧式ColdFusion应用程序,该应用程序大量使用Application.cfm模板文件而不是较新的Application.cfc文件.

I'm in the process of upgrading a large legacy ColdFusion application that heavily utilizes Application.cfm template files instead of the newer Application.cfc files.

似乎Application.cfc为Application.cfm文件可以执行的所有操作提供了更清洁,更有效的解决方案.

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

  • Application.cfm为每个请求按顺序运行每一行,因此 它将在随后的每个新页面查询上重新创建应用程序变量. (如果许多 应用程序变量已加载)The Application.cfc允许某些真正的全局变量,以避免使用onApplicationStart()onRequestStart()方法
  • 重新创建
  • An Application.cfm runs every line sequentially for every request, so it would recreate application variables on every subsequent new page query. (Can cause performance hit if many application variables loaded) The Application.cfc allows for certain truely global variables to avoid getting recreated with the onApplicationStart() and onRequestStart() method

任何人都遇到过任何用例/示例(除了花费明显的移植时间),其中Application.cfm页面比Application.cfc更为可取

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

推荐答案

IMO,这不是一个太宽泛"的话题.这不是意见,我将其归类为最佳做法.

IMO, this is not "too broad" a topic. This isn't an opinion, I'd classify it as a Best Practice.

使用cfc而不是cfm的原因很多.我一直处于这种情况.

There are vast number of reasons to use the cfc over the cfm. I've been in this exact situation.

以下是Application.cfc中可用的常用功能列表您知道):

Here's a list of the common functions available in Application.cfc (I'm sure you're aware):

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

无需深入了解每个细节,能够将您的代码分类到诸如此类的上下文存储桶中,将使您能够更好地管理各种变量范围.没有这些上下文触发器,您只是在Application.cfm的过程方面进行答复.

Without getting into the details of each, having the ability to sort your code into contextual buckets like these will allow you to better manage your various variable scopes. Without these contextual triggers, you're just replying on the procedural aspects of the Application.cfm.

虽然两者都在每个页面请求上运行,但仅运行cfc中的某些功能. cfm,您一直在运行代码,检查何时或不应该运行它的条件.

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

cfm接触当然没有那么大的风险,但是如果要进行升级,则应该期望自己会在整个过程中遇到麻烦.采用最佳做法应是此过程的一部分.

Sticking with the cfm is certainly less risky, but if you're upgrading it, you should expect that you'll break things along the way. Adopting best practices should be part of this process.

这篇关于ColdFusion:在任何用例中,Application.cfm比Application.cfc更可取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆