The following table lists common reasons to employ code reuse methods and indicates the techniques to consider for each purpose. The letter P indicates that the method is preferred. (There can be more than one preferred method.) The letter A means that the method provides an alternative that is useful in some circumstances.
This table does not include CFX tags. You use CFX tags only when it is best to code your functionality in C++ or Java. For more information about using CFX tags, see Using CFX tags.

Purpose

cfinclude tag

Custom tag

UDF

Component

Provide code, including CFML, HTML, and static text, that must be used in multiple pages.

P

 

 

 

Deploy headers and footers.

P

 

 

 

Include one page in another page.

P

     

Divide pages into smaller units.

P

     

Use variables from a calling page.

A

P

P

 

Implement code that uses recursion.

 

P

P

P

Distribute your code to others.

 

P

P

P

Operate on a body of HTML or CFML text.

 

P

 

 

Use subtags.

 

P

 

 

Provide a computation, data manipulation, or other procedure.

 

A

P

 

Provide a single functional element that takes any number of input values and returns a (possibly complex) result.

 

A

P

 

Use variables with names that change from use to use.

 

A

P

P

Provide accessibility from Flash clients.

 

A

A

P

Use built-in user security features.

 

 

A

P

Encapsulate multiple related functions and properties.

 

 

 

P

Create web services.

 

 

 

P

Implement object-oriented coding methodologies.

 

 

 

P

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy