What do you think of using a generic child array instead of explicitly
defining each child array in your parent bean. An example of an
explicit child array would be as follows:

<cfcomponent name="user">
 init()
 get()
 set()
 ...
<cffunction name="getAddress" access="public" output="no" returntype="address">
    <cfreturn variables.address>
 </cffunction>
 <cffunction name="setAddress" access="public" output="no" returntype="void">
    <cfargument name="address" required="yes" type="address">
    <cfset variables.address = arguments.address>
 </cffunction>
</cfcomponent>

I was thinking a generic get and set for child arrays would be nice
for a base object. It would seem to encourage code reuse, just as
generic getters and setters do. Perhaps something like this:

<cffunction name="getChild" access="public" output="no" returntype="array">
 <cfargument name="arrayName" required="yes" hint="The name of the
array to return">
 <cfreturn variables.children.#arguments.arrayName# />
</cffunction>

<cffunction name="setChild" access="public" output="no" returntype="void">
 <cfargument name="arrayName" required="yes" hint="The name of the array">
 <cfargument name="array" required="yes" type="array" hint="The array">
 <cfset arrayAppend(variables.children,#arguments.arrayName#,
#arguments.array#) />
</cffunction>

That code may or may not work, it's just something I mocked up right
now. Who is already doing this? Do you have a generic method for child
objects as well as arrays, or do you fill your array with objects?


You are subscribed to cfcdev. To unsubscribe, please follow the instructions at 
http://www.cfczone.org/listserv.cfm

CFCDev is supported by:
Katapult Media, Inc.
We are cool code geeks looking for fun projects to rock!
www.katapultmedia.com

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

Reply via email to