From: "Jochem van Dieten"
> 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)
I read on, and I still kinda don't understand when you say, "that works with
cfobject and createobject(), but not with cfinvoke.".
So you're saying that if I wanted to use CFINVOKE, that I wouldn't be able
to unless my init() method was returning "this"?
>>> <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
Okay, "that" makes sense. You're able to do that because both methods
(init() and setMode() both return "this"?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
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:188891
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54