Example of name/value pairs:
Say you have a method like this:
<cffunction name="getFoo">
<cfargument name="age">
<cfargument name="gender">
.....
</cffunction>
Using name/value method calling you can do this:
<cfset bar = getFoo(age="26", gender="M")>
-OR-
<cfset bar = getFoo(gender="M", age="26")>
That is, its not based on position, where you declared "age" first and then "gender" in the
cffunction declaration.
For large amounts of optional parameters (e.g. 4 or 5 or 6, etc), this can be handy. Rather than
specify the parameters that are optional but use default values for them ('' or 0) you can just
explicitly name the ones you are passing in.
/Cody
Dave Watts wrote:
In the meantime, I am wondering if this is even a good idea.
It seems to me like it kind of violates the principles of
encapsulation and data hiding. What do you think?
There's nothing wrong with using named notation. To call a function, you
need to know something about the data it expects to receive. That something
could either be the names of the parameters, or their respective positions.
Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]