How about:
<cffunction name="save" output="no" etc>
<cfargument name="theThing" type="any" required="yes">
<cfargument name="theBits" type="any" required="no">
<cfargument name="theOhterBits" type="any" required="no">
<cfif isStruct(arguments.theThing)>
<cfreturn saveStruct(arguments.theThing)>
<cfelseif isObject(arguments.theThing)>
<!--- check arrayLen(arguments) etc --->
<cfreturn saveObject(arguments.theThing)>
<cfelse>
etc
</cfif>
</cffunction>
Aaron
Aaron Roberson wrote:
Peter,
Thanks for that very informative reply. I think I will take Patrick
and your advice and create two methods, one as saveObject() and the
other as saveStruct().
@Patrick - To answer your question, I percieved both methods as
ultimately doing the same thing (persisting an object) and didn't
think having two methods was a good design choice. However, I think I
can live with saveStruct() as a second method since it does represent
a concrete difference between the two methods.
Thanks,
Aaron
On 4/24/07, Peter Bell <[EMAIL PROTECTED]> wrote:
+1, I support both approaches, but one is saving an object so I call it
saveObject(Object: object) and the other is saveStruct(Struct: struct,
PropertyNameList: string). In the first I'm taking a well formed
object and
depending on my implementation either asking it to save itself or
asking it
for its properties and looping through them using a getter to build the
appropriate insert or update SQL. In the second I call a factory for
a new
object (encapsulated via ObjectService.new()), then I
Object.loadStruct()
and then I call saveObject() on the object I just loaded.
I definitely see two different intents and methods as being appropriate
here.
Best Wishes,
Peter
On 4/24/07 8:53 PM, "Patrick McElhaney" <[EMAIL PROTECTED]> wrote:
Why do you need method overloading? Why can't you just have two
different
methods with different names? It looks like the methods aren't really
doing
the same thing anyway. The first takes an existing object and saves
it. The
second creates a new object and saves it.
Patrick
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/cfcdev@cfczone.org
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/cfcdev@cfczone.org