Default Arguments

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • burgermeister01@gmail.com

    Default Arguments

    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...slop py. 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!
  • Chuck

    #2
    Re: Default Arguments


    <burgermeister0 1@gmail.comwrot e in message
    news:577f3c06-6992-40db-a8f2-d72495e0b997@25 g2000hsx.google groups.com...
    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...slop py.
    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.


    Comment

    • Jerry Stuckle

      #3
      Re: Default Arguments

      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...slop py. 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@attgl obal.net
      =============== ===

      Comment

      • Chuck

        #4
        Re: Default Arguments


        "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
        news:g5r01f$8io $1@registered.m otzarella.org.. .
        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...slo ppy. 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.


        Comment

        Working...