On 4/13/05, Mark Kecko <[EMAIL PROTECTED]> wrote:
> In addition to my original post below, I have a question about the
> instance scope. What is it and should I be using it?
It's just a programming convention. I actually don't recommend using it.
> <cfcomponent displayname="Member Qualifiers">
> <cfproperty name="id" type="numeric" default="0">
> <cfproperty name="name" type="string">
> <cfproperty name="email" type="string">
<cfproperty> is pointless unless you're writing a complex web service.
Don't use it, it will only confuse you and anyone else who reads your
code.
> <cffunction name="init" access="public" output="false"
> returntype="struct">
> <cfargument name="aid" type="numeric" default="0">
> <cfscript>
> instance = structNew();
I think this is bad practice. It's equivalent to:
variables.instance = structNew();
> instance.id = id;
> instance.name = "";
Frankly, I'd just use the variables scope directly - omit the
structNew() line above and just do this instead:
variables.id = id;
variables.name = "";
> <cfquery name="member" maxrows="1" datasource="mp2">
Be warned that this is not thread safe. All function-local variables -
including those created by CF tags - should be declared at the top of
the function using 'var', e.g.,
<cfset var member = 0/>
...
<cfquery name="member" ..>
> <cfset this.init(arguments.aid)>
When you're making calls to methods on the same object, don't use
'this.', just call the method:
<cfset init(arguments.aid) />
> <cfquery name="member_update" datasource="mp2">
Again, var-declare member_update for safety.
--
Sean A Corfield -- http://corfield.org/
Team Fusebox -- http://fusebox.org/
Got Gmail? -- I have 50, yes 50, invites to give away!
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:12:6728
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/12
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:12
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.12
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54