Yes, I also noticed this.
 
I made a test where a cfloop is done on 2000 records and had three
setups:
 
1) cfloop / createObject on a CFC "Bean" / add this CFC instance to an
Array
2) cfloop / createObject on a JavaBean (same as Erik mentions) / add
this bean to an Array
3) cloop / delegate object creation to a Java class (instatiated
upfront)  / Java class returns JavaBean / add bean to Array
 
1) is slooooooooooow (like 5000ms)
2) is fast! (like 50ms)
3) is fastest (like 30ms)
 
the difference between 2) and 3) is not significant. But the difference
between 1) and 2) is!
 
I think the main problem is that CFC instances are not really comparable
to JavaBeans / Valueobjects at runtime because every single method
(getter/setter) of a CFC gets compiled into a single class. So a
Person.cfc with 20 properties implemented as getters/setters gets
compiled into at least 40 classes (one for every getter and one for
every setter) plus some more stub code.
 
I think this is the main reason why creating CFC ValueObjects / Beans is
so expensive inside loops.
 
IMHO it should not be regarded best practice to use CFCs as VOs - this
may work for simple tasks but is definitely not good for more compley
setups (e.g. using CFCs to get typed objects in the Flex frontend)
 
Dirk.



________________________________

        From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of EECOLOR
        Sent: Wednesday, November 22, 2006 2:35 PM
        To: [email protected]
        Subject: Re: [flexcoders] ColdFusion and Flex Integration - up
to 10x gain, avoid cf object creation
        
        
        Some time ago i experienced with java versions of the value
objects. This also gives a significant improvement.
         
         
        Greetz Erik
        

Reply via email to