Deprecated Code

Overview

Deprecated code and features are those that have been retired and replaced by alternative functionality. These features should not be used, and remain in the code base for the sole purpose of providing backward compatibility. You can assume that at some point this code will be removed, so developers should make every effort to refactor code relying on deprecated elements of the framework.

Deprecated Logging

In an effort to make detecting the use of deprecated code easier, we have tried to integrate an option for logging the use of deprecated features. Where possible we log the use of a deprecated feature and suggest an alternative.

You can turn on logging by setting a flag for application.log.bDeprecated in your project's ./config/_serverSpecificVars.cfm

./config/_serverSpecificVars.cfm
<cfset application.log.bDeprecated = true />

As you use your application a log called deprecated.log will be generated in your servers logging directory. You can reach this through the CFIDE administrator logging area. In addition, a trace will be made at runtime into your debugging output; you will need to activate view CFTRACE in your debugging to see this.

Flagging Code As Deprecated

Issue Tracking

Ensure you have:

  1. Created a ticket in the community bug tracker that explains why the code is being deprecated and is flagged as issue type "Deprecated".
  2. Added the ticket subject and number to your commit log; eg. FC-123: this code has been deprecated blah, blah
  3. Resolve/Close ticket and assigned to the correct Fix Version

Good work!

Inline Code

As a core developer you can flag deprecated code by including this following snippet:

Example Deprecated Code Snippet
<cfimport taglib="/farcry/core/tags/farcry" prefix="farcry" />
<farcry:deprecated message="../admin/navajo/edit.cfm should be replaced by call to ../conjuror/invocation.cfm" />

The log message should specify what deprecated feature is being used and the alternative feature/function that should be used in its stead.

Innards

./tags/farcry/deprecated.cfm
<cfsetting enablecfoutputonly="true">
<!--- @@Copyright: Daemon Pty Limited 1995-2007, http://www.daemon.com.au --->
<!--- @@License: Released Under the "Common Public License 1.0", http://www.opensource.org/licenses/cpl.php --->
<!--- @@displayname: Deprecated Tag --->
<!--- @@description:  As a core developer you can flag deprecated code by using this tag to pass in a deprecated message --->
<!--- @@author: Matthew Bryant (mbryant@daemon.com.au) --->

<cfif thistag.executionMode eq "Start">

	<cfparam name="attributes.message" type="string" />

	<cfif isdefined("application.log.bDeprecated") AND application.log.bDeprecated>		
		<cftrace type="warning" inline="false" text="#GetBaseTemplatePath()# - #attributes.message#" abort="false" />
		<cflog file="deprecated" application="true" type="warning" text="#GetBaseTemplatePath()# - #attributes.message#" />
	</cfif>
	
</cfif>

<cfsetting enablecfoutputonly="false">