Click here to get back home

Default Arguments

 HomeNewsGroups | Search | About
 comp.lang.php    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Default Arguments burgermeister01@gmail.com 07-18-2008
Get Chitika Premium
Posted by burgermeister01@gmail.com on July 18, 2008, 4:02 pm
Please log in for more thread options
Default Arguments: what's the general consensus about them? To give an
example, so we're all on the same page, this is the syntax I'm talking
about:

function foo($bar = "some value"){
}


So, in the past when I was programming with PHP a lot, I found myself
using default arguments more and more because they were so convenient.
But in the back of my mind, something about them seemed
somewhat...sloppy. I've never had the privilege of working on a
project quite large enough for architectural weaknesses to really show
their strain, so I'd like to pose this question to other minds, to see
if any of you have input about this syntactical tool.

Thanks!

Posted by Chuck on July 18, 2008, 4:18 pm
Please log in for more thread options

> Default Arguments: what's the general consensus about them? To give an
> example, so we're all on the same page, this is the syntax I'm talking
> about:
>
> function foo($bar = "some value"){
> }
>
>
> So, in the past when I was programming with PHP a lot, I found myself
> using default arguments more and more because they were so convenient.
> But in the back of my mind, something about them seemed
> somewhat...sloppy.

misconception major...number 1

> I've never had the privilege of working on a
> project quite large enough for architectural weaknesses to really show
> their strain, so I'd like to pose this question to other minds, to see
> if any of you have input about this syntactical tool.

it's a convenience. if i have a function that has umphteen args and they
don't have default values, i have to have an ugly mess of '', '' or null,
null, null or whatever. it is much cleaner only supplying arguments that are
ACTUALLY needed. it's stupidity not to.



Posted by Jerry Stuckle on July 18, 2008, 4:53 pm
Please log in for more thread options
burgermeister01@gmail.com wrote:
> Default Arguments: what's the general consensus about them? To give an
> example, so we're all on the same page, this is the syntax I'm talking
> about:
>
> function foo($bar = "some value"){
> }
>
>
> So, in the past when I was programming with PHP a lot, I found myself
> using default arguments more and more because they were so convenient.
> But in the back of my mind, something about them seemed
> somewhat...sloppy. I've never had the privilege of working on a
> project quite large enough for architectural weaknesses to really show
> their strain, so I'd like to pose this question to other minds, to see
> if any of you have input about this syntactical tool.
>
> Thanks!
>

I think default arguments are fine if you have a specific default
argument to pass. It just helps keep the code cleaner.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================


Posted by Chuck on July 18, 2008, 9:49 pm
Please log in for more thread options

> burgermeister01@gmail.com wrote:
>> Default Arguments: what's the general consensus about them? To give an
>> example, so we're all on the same page, this is the syntax I'm talking
>> about:
>>
>> function foo($bar = "some value"){
>> }
>>
>>
>> So, in the past when I was programming with PHP a lot, I found myself
>> using default arguments more and more because they were so convenient.
>> But in the back of my mind, something about them seemed
>> somewhat...sloppy. I've never had the privilege of working on a
>> project quite large enough for architectural weaknesses to really show
>> their strain, so I'd like to pose this question to other minds, to see
>> if any of you have input about this syntactical tool.
>>
>> Thanks!
>>
>
> I think default arguments are fine if you have a specific default argument
> to pass. It just helps keep the code cleaner.

I just wish php supported named arguments too.



Similar ThreadsPosted
GD default DPI February 1, 2005, 9:12 am
url arguments ? October 12, 2006, 10:45 am
PHP Cli arguments December 28, 2007, 9:21 am
Default parameter November 15, 2004, 5:10 pm
Default 2147483647 October 25, 2005, 5:55 am
[authlib] Why "id int(11) DEFAULT '0'"? June 8, 2007, 5:04 pm
arguments from function September 15, 2006, 7:24 am
Name of function arguments January 25, 2008, 9:08 am
Can a default value be specified for a drop-down list? September 24, 2004, 5:59 pm
default argument values March 16, 2006, 4:50 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap