>As pointed out elsewhere, arrays are copied by value 

I thought CFMX Arrays are Java Vectors and Not really Primitive
Java Arrays. So arent arrays passed by Reference.. since they
are true objects?

Am i missing something?

Thanks,
Joe Eugene


>-----Original Message-----
>From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
>Behalf Of Sean A Corfield
>Sent: Friday, April 02, 2004 6:49 PM
>To: [EMAIL PROTECTED]
>Subject: Re: [CFCDev] Protecting private Array variables using get/set
>
>
>On Apr 2, 2004, at 8:11 AM, John Temm wrote:
>> Ideas? Is it generally not a good idea to use arrays for properties 
>> because of this?
>
>As pointed out elsewhere, arrays are copied by value so where you can 
>actually get into trouble is if you try to use the getArrayProperty() 
>method internally to operate on the elements (rather than using 
>variables.arrayProperty directly). It's one of the few places where you 
>can't exclusively use getters inside your components - but you could 
>setArrayPropertyAt(value,index) / getArrayPropertyAt(index) if you 
>needed to encapsulate raw access to the array...
>
>However, if you're concerned about passing references out of getters, a 
>more common pitfall is when folks return a struct property and forget 
>to duplicate() it. Of course, in most cases you wouldn't return a plain 
>struct - you'd either return the components of the struct separately 
>(in separate getters) or you'd want to encapsulate the structured data 
>in another component, i.e., use a CFC instead of a struct.
>
>Finally, passing arrays around might be a performance concern - since 
>the entire array is copied on every assignment. Not really a problem 
>for small arrays but I've seen CFers innocently pass around large 
>arrays with abandon...
>
>Regards,
>Sean
>
>----------------------------------------------------------
>You are subscribed to cfcdev. To unsubscribe, send an email
>to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
>in the message of the email.
>
>CFCDev is run by CFCZone (www.cfczone.org) and supported
>by Mindtool, Corporation (www.mindtool.com).
>
>An archive of the CFCDev list is available at 
>www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the words 'unsubscribe cfcdev' 
in the message of the email.

CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).

An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]

Reply via email to