On Wed, Apr 18, 2012 at 1:56 AM, Alexey Shein <con...@gmail.com> wrote:

> Hi!
>
> My opinion is that solution tries to overcome bad consequences of
> legacy code, when it's not feasible to change something without
> breakage a lot of code, although the real solution is to refactor
> functions with long variable lists (as Uncle Bob says), maybe this
> should be noted in documentation of this feature.
>

I disagree with the suggestion that the "real" solution is to refactor
functions. Is a function with 3 parameters too long?

function foo($val1, $val2 = true, $val3 = false) { /* code */}

If I want to pass in a value to the third argument but keep the default
value for the second argument, I have to look up what the default is and
then paste/type it in as the second argument.

Being able to just call foo($val1 = "something", , $val3 = true) lets me
set a specific value for the 3rd argument without having to do any hunting
down of the 2nd default value or copying/pasting/typing in the argument.

>From my perspective, this solution is more about maintaining defaults and
improving developer experience than about problems with legacy code, and it
holds value for any function that has more than one default value.

Adam

Reply via email to