+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
> 
> 
> 
> On 4/24/07, Aaron Roberson <[EMAIL PROTECTED]> wrote:
>> I have a question that could be answered with method overloading but
>> since CFML is dynamic we don't have that option. What I do you suggest
>> I do instead?
>> 
>> In my service layer I have a method called saveObject(). At present it
>> takes an object as the argument and does this simple bit:
>> 
>> return variables.objectDAO.save(object);
>> 
>> At times, it seems that I can pull more logic out of the controller
>> and placing it in my service layer by passing in parameters for each
>> property of the object. Then in the saveObject() method I would have
>> the following:
>> 
>> object = createObject("component","path.to.object");
>> object.setProperty1(arguments.property1);
>> object.setProperty2 (arguments.property2);
>> ....
>> return variables.objectDAO.save(object);
>> 
>> Both of these approaches are valid and have their place. If we could
>> do method overloading I would create both methods and the problem
>> would be solved. Since we can't, what do you suggest I do instead?
>> 
>> Obviously I have to abandon one in favor of the other. Which approach
>> do you use and why?
>> 
>> Thanks,
>> Aaron
>> 
>> 
>> 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 <http://www.katapultmedia.com>
>> 
>> An archive of the CFCDev list is available at
>> www.mail-archive.com/cfcdev@cfczone.org
>> <http://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

Reply via email to