On Fri, 24 Dec 2004 21:26:18 -0600, Jared Rypka-Hauer - CMG, LLC
<[EMAIL PROTECTED]> wrote:
> Right... This is for moving from say... the DB to the screen via a
> single method call i.e. thisUser.get(12)
> <cfoutput>thisUser.fname</cfoutput>

You're relying on the public "this" scope in order to be able to
directly access data members from outside the object. A lot of people
think this is a bad idea and you should use "variables" scope instead
and provide 'get' functions for the attributes:

<cfoutput>#thisUser.getFName()#</cfoutput>

This prevents accidental modification of data within the object.

> where inside the CFC this.fName = query.fname and this.fName =
> query.lName and init(12) is passing the table's pkey value (possibly a

So you'd either say:
    variables.fName = query.fName;
    variables.lName = query.lName;
or:
    setFName(query.fName);
    setLName(query.lName);
if you used public or private set methods instead.

> I've got that THIS thing down fine. I guess it's the difference
> between private instance data and function-private variables that has
> me a little puzzled.

<cffunction name="foo">
    <cfset var x = "exists only for this call of foo"/>
    <cfset y = "exists across all calls for the same instance"/>
    <cfset variables.z = "same scope as y"/>
</cffunction>

None of x, y or z can be accessed from outside the object. x is
created fresh for every call of foo() (and is therefore thread safe).
y and z are created on the first call but the same y and z are updated
on subsequent calls (for the same instance).

If the instance is in application scope, x is still local but y and z
are effectively application scope variables.

> And even at that, I can see why one would choose to use function
> private variables for somethings,

"function local" - private means something else.
-- 
Sean A Corfield -- http://www.corfield.org/
Team Fusebox -- http://www.fusebox.org/
Breeze Me! -- http://www.corfield.org/breezeme
Got Gmail? -- I have 6 invites to give away!

"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Special thanks to the CF Community Suite Silver Sponsor - CFDynamics
http://www.cfdynamics.com

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:188779
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

Reply via email to