Jeff Small wrote:
>> 
>> 5) One practice that has become a "best practice" of sorts is to
>> return "this" from your init method so that you can method chain, as
>> shown below. Granted, not everybody follows this practice, as it's
>> more personal preference, but it's just what I'm used to now.
> 
> I'm struggling with "this". I don't understand even from Seans's post what 
> purpose it serves to return "this" when you're using something like CFOBJECT 
> or "CreateObject()" which creates an instance of an object anyway...

Because that works with cfobject and createobject(), but not with 
cfinvoke. (read on)


>> <cffunction name="setDSN" access="private" output="false" returntype="void" 
>> hint="Sets the name of the datasource">
>>    <cfargument name="dsName" type="string" required="true" hint="The 
>> datasource name to set">
>>    <cfset variables.DSN = arguments.dsName>
>> </cffunction>

If you have your setters return "this" too, you can chain them 
together:

<cfset variables.myCFC.setDSN("dsn").setMode("READONLY")>

Jochem

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Gold Sponsor - CFHosting.net
http://www.cfhosting.net

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188880
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to