So, I'm relatively new to OO in ColdFusion, and I'm banging my head against one 
issue in particular.  Let's say I've got a DAO or Gateway object in my 
APPLICATION scope that needs to return a collection of beans, I'm having 
trouble understanding the need to VAR scope all internally used variables when 
I've got a dynamic number of objects being returned.  That's not very clear, so 
let's say this is the function in question:

<cffunction name="getContacts" access="public" returntype="Contact[]">

   <cfset returnArray = ArrayNew()>
   <cfset q_Contacts = "">

   <cfquery name="q_Contacts">
   SELECT *
   FROM Contacts
   </cfquery>

  <cfloop query="q_Contacts">
       <cfset thisContact = createObject('component', 'Contact').init(...insert 
init info here...)>
       <cfset ArrayAppend(returnArray, thisContact)>
  </cfloop>

  <cfreturn returnArray>
</cffunction>

So, my concern is with the inability to create the Contact objects in the VAR 
scope since I don't know how many I'll be creating before hand.  If I do it 
like this (i.e. without the VAR on the createObject), am I setting myself up 
problems?  If so, how should I handle this?

Thanks again, and I hope it's not to ridiculous a question.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:329652
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