Viewing Individual Entry / Main
  ::   May 5, 2003

Interesting Discussion on Required vs. Optional CFC/UDF Arguments
I sparked an interesting discussion on the cfcdev mailing list today. At issue is an inconsistency between the way the cfargument tag is documented and the way CF MX (updater 3) implements it.

The docs state that the required attribute of the cffunciton tag is "A type; if no argument is passed, specifies a default argument value. If this attribute is present, the required attribute must be set to "no" or not specified."

However, in implementation, the cfargument tag allows you to specify both required="yes" AND default="some value". To me, this seems wrong. If we use ColdFusion's built in functions (BIFs) as an example, if an argument is required, then the function required you to pass it in. It does not set a default value in the event you choose not to pass a value in. If it does provide a default value, then the argument is optional.

Some posters on the list argued (and I can agree with this) that the required attribute is redundant in that if you specify a default value, then the argument is by definition optional. Unfortunately, since CF MX introduced the required attribute, I doubt Macromedia will ever take it away as it could break backward compatability. That said, I'd really like to see Macromedia "fix" cfargument in the next updater or release of CF MX so that it mirrors the behavior outlined in the documentation.



Calendar
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            

Recommended Reading
Things Fall Apart : A Novel

Archives by Subject
Announcements (28)
ColdFusion (61)
Database (12)
Dreamweaver (1)
Flash (2)
Flash Remoting (2)
Flex (3)
General Development (2)
Homesite + (1)
Mach-II (3)
MAX (9)
Mozilla (2)
Music (1)
Politics (1)
Portals (2)
Travel (2)

Search

Links
CFLib.org
Raymond Camden's Blog
Christian Cantrell's Blog
Sean Corfield's Blog
Nathan Dintenfass' Blog
Todd Rafferty's Blog
Steve Rittler's Blog
Cameron Childress's Blog

Credits
Based on blog.cfc by Raymond Camden

XML Feed