Common Factory wha? Curious that noone offered it as a solution when the question was first asked, over a week ago... How common is common?

The difference between my suggestion and the way C++ (for example, I won't speak to Java although it may be the same) implements method overloading is C++ does it at compile time and we're doing it at runtime.

To the best of my knowledge, C++ uses name mangling to implement method overloading. So at compile time, the declarations:

test(int int1, int2)      AND
test(int int1, int2, int3)

generate resulting functions called (for example):

test_i_i(int int1, int2)            AND
test_i_i_i(int int1, int2, int3)

When either of these functions is called, the compiler looks at the argument types being passed and how many there are, and generates a call to the correct function:

int i = 12;
test(1, 2) ==> test_i_i(1, 2);
test(1, 2, i) ==> test_i_i_i(1, 2, i);

Cold Fusion will only be able to do *this* implementation if it becomes strongly typed. Sure, you can specify argument types, but they can be pretty darn flexible.

<cffunction name="test" output="yes">
   <cfargument name="in" type="string">
   <cfoutput>
       in = #arguments.in#
   </cfoutput>
</cffunction>

<cfscript>
   test(1);
   test("1");
</cfscript>

Works fine on CF7. To use name mangling would require having to define array and structure content types, etc. Which in turn would reduce the flexibility and ease of use of the language significantly. Not too sure I'm as keen for strong typing just so we can do "normal" method overloading as some :)

Aaron


Andrew Scott wrote:
Aaron,
First of all, there as been a many times for a need for it, and placed it on the requested feature list many months ago. But as for important enough to make it into CF8, no but bloody would be a fantastic addition whatever version it makes it into. Because your solution is a very commin factory facade, and secondly your solution is one of many reasons to have it.


On 5/4/07, *Aaron DC* <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    If you can simulate it (as in the example I just showed), does it
    really
    matter if it makes it into CF8?

    Aaron

    Andrew Scott wrote:
    > +1...
    >
    > I agree, it would so good if we could create methods with different
    > arguments. I have flagged this as a wish, so I doubt it will make
    > CF8... But who knows...
    >
    >
    >
    > On 4/25/07, *Aaron Roberson* <[EMAIL PROTECTED]
    <mailto:[EMAIL PROTECTED]>
    > <mailto:[EMAIL PROTECTED] <mailto:[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>
    <http://www.katapultmedia.com>
    >
    >     An archive of the CFCDev list is available at
    >     www.mail-archive.com/[email protected]
    <http://www.mail-archive.com/[email protected]>
    >     <http://www.mail-archive.com/[email protected]>
    >
    >
    >
    >
    > --
    >
    >
    >
    > Senior Coldfusion Developer
    > Aegeon Pty. Ltd.
    > www.aegeon.com.au <http://www.aegeon.com.au>
    <http://www.aegeon.com.au>
    > Phone: +613  8676 4223
    > Mobile: 0404 998 273
    > 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/[email protected]
    <http://www.mail-archive.com/[email protected]>


    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/[email protected]
    <http://www.mail-archive.com/[email protected]>




--



Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au <http://www.aegeon.com.au>
Phone: +613  8676 4223
Mobile: 0404 998 273
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]


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