Adam Cameron wrote:
NO... there are no naming collisions. The only attributes are the field
    
names.


Yeah, there could be.  Consider this code:

<!--- c.cfc --->
<cfcomponent>
	<cffunction name="f">
		<cfset this.f = "fubar">
		<cfreturn "So far, so good">
	</cffunction>

	<cffunction name="g">
		<cfreturn "No worries">
	</cffunction>

</cfcomponent>


<!--- caller.cfm --->
<cfset o = createObject("component", "c")>
<cfoutput>
	#o.f()#<br />
	<cftry>
		#o.f()#<br />
		<cfcatch>
			<cfdump var="#o#" label="It doesn't work because
you've overwritten the function f() with the string 'fubar'">
		</cfcatch>
	</cftry>
	<hr />
	#o.g()#<br />
	<cfset o.g = "more fubar">
	<cftry>
		#o.g()#<br />
		<cfcatch>
			<cfdump var="#o#" label="It doesn't work because
you've overwritten the function g() with the string 'more fubar'">
		</cfcatch>
	</cftry>
</cfoutput>

So if you have a query column name that's the same as any of your public
method names... no good.  Hence my suggestion to put them in a separate
structure.

This method overwriting thing is an interesting quirk of CF.  Simultaneously
handy to know, but somewhat scary.  And probably not a very good "feature".
But no doubt it was designed that way, so it's fine ;-)
  
I understand what your example was saying... but we don't do any of that. That would create an error.

Using "this.myField"
#o.myField#

using a function called myField
<cfscript>
o.myField();
</cfscript>
I address the "This scope" as attributes. If someone creates a datafield that matches a function name they are both existing with simular "name" but they are independent unless someone violates good code and uses the code to set the this scope. In the oquery.cfc this should be avoided. Only the setattributes function should be used... and if you will notice the function is private to prevent the outside world from using it.

Also... in answer to why I duplicate the query recordset rather than referencing it some have asked. It also creates a more encapsulated object. It keeps the internals of the object isolated from the outside world. They can execute methods... read attributes... and that keeps the recordset hidden.

John
---------------------------------------------------------- You are subscribed to cfcdev. To unsubscribe, send an email to [email protected] with the words 'unsubscribe cfcdev' as the subject of the email. CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting (www.cfxhosting.com). An archive of the CFCDev list is available at www.mail-archive.com/[email protected]

Reply via email to