Even though it works, it is not a normal practice for the guts of a
component to know what is going on outside.

Alghouth it's a reach, it is possible that your update_product method
could accept URL variables, rather than form variables.  If this were
true, then you would have to modify your method.

However, if you called the update_product method, and passed in the form
scope, you would not have to change your method.

For example:

<cfset myObj.update_product(form, product_id)>

<cffunction name="update_product" ...>

    <cfargument name="updateStruct" ...>
    <cfargument name="product_id" ...>

</cffunction> 

Could easily be changed to:

<cfset myObj.update_product(url, product_id)>

without having to touch your update_product method.

Like I said, even though it works, most people try to avoid referencing
external scopes outside the component.  The worst-case scenario would be
that you may be put on someone's do-not-hire list because they are
sticklers for things such as this.  ;^)

Mike

-----Original Message-----
From: Rick Faircloth [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 22, 2008 9:10 AM
To: cf-talk
Subject: How can this CFC be improved?

Hi, all... still trying to get a handle on using CFC's.

Here's an update method I wrote and I'd like to know what can be changed
to make it better.  Such as, why not use the form scope in the query?
And, why not just use the application scope for the dsn, instead of
converting it to the variables scope?

If components have access to the url, form, session, and application
scopes, etc., why not use them in the component?
What's the benefit of converting them?


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:314217
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to