The practice of protecting access
In CFC methods, there is an attribute called "access". The access methods are explained in Chapter 2, Basic CFCs and Database Interaction. Some methods within a CFC are more examples of reuse. We have updated the sample code for _product.cfc
in addition to what you had in the previous chapter. It is an example of a power CFC. There is a method inside the CFC called setDefaults()
. The variable variables.field.names
comes from another location in our CFC:
<cffunction name="setDefaults" access="private" output="false"> <cfset var iAttr = 0> <cfloop list="#listLen(variables.field.names)#" index="iAttr"> <cfscript> variables.attribute[#listGetAt(variables.field.names,iAttr)#] = setDefault(variables.field.names,iAttr); </cfscript> </cfloop> </cffunction>
The logic for this would actually be used in more than one place inside the object. When the object is created during the first run, it would call...