[nycphp-talk] function references
Hans Zaunere
lists at zaunere.com
Sun Jan 11 14:21:01 EST 2009
> >> $foo = new Bar();
> >> $a = 'my_method';
> >> $result = $foo->{$a}();
> >>
> >> Very useful sometimes.
> >
> > Yes, but indirection can easily be overused. Please don't overuse as it
> > makes reading other's code that much harder.
> >
>
> Hah, just imagining a project from hell that would define() all of the
> method names in an include and then make calls like the following:
>
> $result = $foo->{ MY_METHOD_1 }();
>
> ... because then if the foo interface ever changes, all you have to do
> is update the include file. :-D
That's crazy talk.
-- defining/reading constants is expensive - performance
-- when an interface to an object changes, it's likely going to be more than
just syntactic sugar and the names of the methods
-- looks weird
-- it's just strange
-- indirection is never implemented in an organized way
There, I said it :)
H
More information about the talk
mailing list