Casey Dougall wrote:
On 7/2/07, *Nando* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
<cfcomponent displayName="List" hint="I'm a List that belongs to a
certain User" output="false">
<cffunction name="init" access="public" output="false">
<cfargument name="ListID" type="string" required="false"
default="" />
<cfargument name="UserID" type="string" required="false"
default="" />
<cfargument name="ListName" type="string" required="false"
default="" />
<cfset setListID(arguments.ListID) />
<cfset setUserID(arguments.UserID) />
<cfset setListName(arguments.ListName) />
<cfreturn this />
</cffunction>
I'm not a OO guy myself but found it interesting as anything at
cfunited. My question about the above deals about changing the order
of arguments. I haven't see anything that really deals with this and I
would think this is one of the biggest challenges with anything using
components and at some point adding on to an application from
somewhere in the middle.
Using the example above, a few months down the line you need to access
this list not by ListID, but by ListCategoryID. Now where this may be
the last argument used, is this the best way to go about designing
cffunctions? I'd like to put ListCategoryID first without messing up
my scripts that depend on ListID being first. What's the best way to
handle this?
As you mention, there really is no way to handle it. Either put it last
and make it not required, create a new function, or start naming your
arguments everywhere. Of course, you could also just bite the bullet
and go change all that other code as well. Most people choose a
different option, however.
There may be other ways, but those are the 4 that stick out at the moment.
Finally, there are refactoring tools in other languages that might be
able to help you in those languages, but not CF. Also, method
overloading is available in many statically typed languages.
Sam
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