You are right, I meant duplicate()
<cfset var structName = duplicate(arguments.structName) />
NOT
<cfset var structName = .. />

 
On 9/8/06, Daniel Elmore <[EMAIL PROTECTED]> wrote:
Sophek, I wouldn't follow OOP practices verbatim or with religious zeal. Do
what works best for your application. If you do it wrong, you'll learn from
it and choose wiser next time. This way you'll learn to "see" OOP value.

The arguments scope is thread safe, as it is created per-method call. So you
don't need to copy it into the var scope.

As for performance, structs as passed by reference, not by value, so your
performance might actually go up. But I hope your not worry about that part,
as we are talking about nanoseconds here.


Daniel Elmore



-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ]
On Behalf Of Sophek Tounn
Sent: Friday, September 08, 2006 10:20 AM
To: Dallas/Fort Worth ColdFusion User Group Mailing List
Subject: Re: [DFW CFUG] Is this bad practice?

Thanks AHMED,

I know in the OOP world, I should also have getters and setters, seems to me
CF becoming something other than CF.

thanks
Sophek
On 9/7/06, AHMED EL-RASHEEDY <[EMAIL PROTECTED]> wrote:
I have done this before and found no performance issues with it.

The only short coming is if someone else would want to reuse yourCFC
ormethod and the struct and its keys are not documented.It would be a good
idea to put in the hint or some commentfor the cfargument to explain what
is expected in the passed struct.

Also, it is good idea to copy the struct to a var scoped struct in case you
will change any of the values in the keys.

Ahmed.

On 9/7/06, Sophek Tounn < [EMAIL PROTECTED]> wrote:
Hi all,

I have a component that has only one argument: Is it okay pass a struct to 1
argument as oppose to creating many arguments?

<cfcomponent>
<cffunction name="addToCustomers" access="public" returntype="void">
<cfargument name="structCollection" type="struct">
<cfset createID = createUUID()>
<cfquery name="qAddtoCustomers" datasource="#request.dsn#">
  INSERT INTO customers (
  customers_id,
  customers_gender,
  customers_firstname,
  customers_lastname,
  customers_dob,
  customers_email_address,
  customers_nick,
  customers_default_address_id,
  customers_telephone,
  customers_fax,
  customers_password,
  customers_newsletter,
  customers_group_pricing,
  customers_email_format,
  customers_authorization,
  customers_referral)
  VALUES (
  <cfqueryparam value="#createID#" cfsqltype="cf_sql_varchar"
/>,
  <cfqueryparam
value="#arguments.structCollection.customers_gender#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_firstname#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_lastname#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#createODBCDateTime( arguments.structCollection.customers_dob)#"
cfsqltype="cf_sql_date">,
  <cfqueryparam
value="#arguments.structCollection.customers_email_address#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_nick#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_default_address_id#"
cfsqltype="cf_sql_numeric">,
  <cfqueryparam
value="#arguments.structCollection.customers_telephone#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_fax#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_password#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_newsletter#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_group_pricing#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_email_format#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_authorization#"
cfsqltype="cf_sql_varchar">,
  <cfqueryparam
value="#arguments.structCollection.customers_referral#"
cfsqltype="cf_sql_varchar">)
  </cfquery>
</cffunction>
</cfcomponent>

thanks

sophek


_______________________________________________
Reply to DFWCFUG:
[email protected]
Subscribe/Unsubscribe:
http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
http://www.mail-archive.com/list%40list.dfwcfug.org/
http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
www.HostMySite.com
www.teksystems.com/



_______________________________________________
Reply to DFWCFUG:
[email protected]
Subscribe/Unsubscribe:
http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
  http://www.mail-archive.com/list%40list.dfwcfug.org/
http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
www.HostMySite.com
www.teksystems.com/




_______________________________________________
Reply to DFWCFUG:
[email protected]
Subscribe/Unsubscribe:
http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives:
   http://www.mail-archive.com/list%40list.dfwcfug.org/
http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors:
www.HostMySite.com
www.teksystems.com/

_______________________________________________
Reply to DFWCFUG: 
  [email protected]
Subscribe/Unsubscribe: 
  http://lists1.safesecureweb.com/mailman/listinfo/list
List Archives: 
    http://www.mail-archive.com/list%40list.dfwcfug.org/             
  http://www.mail-archive.com/list%40dfwcfug.org/
DFWCFUG Sponsors: 
  www.HostMySite.com 
  www.teksystems.com/

Reply via email to