RE: [PHP-DEV] reference caller object
| From: | Jared Williams | Date: | Sat, 19 Sep 2009 14:04:28 +0000 |
| Subject: | RE: [PHP-DEV] reference caller object | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45613@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Stan Vassilev [mailto:sv_forums@fmethod.com]
> Sent: 19 September 2009 11:33
> To: troels knak-nielsen; Ford, Mike
> Cc: internals@lists.php.net
> Subject: Re: [PHP-DEV] reference caller object
>
> >I, for one, am quite happy that it's fairly complicated and
> convoluted
> >to get the caller of a method, since it could lead to some
> seriously
> >incomprehensible code in the hands of someone who don't know
> what they
> >are doing. Requiring the user to use the backtrace is a
> clear warning
> >sign, and I think that's a good thing.
>
>
> What is the basis for all this. When someone says a feature
> is "ugly" and it leading to "seriously incomprehensible
> code", I'd really like this is explained and supported by
> evidence somehow, than just thrown around without facts.
>
> Most OOP languages expose the caller in some fashion. You'll
> be hard at work to see in which of them it led to masses of
> convoluted code.
>
It is considered a code smell, using instanceof in conditionals.
http://c2.com/cgi/wiki?InstanceofInConditionals
And should be refactored with...
http://c2.com/cgi/wiki?ReplaceConditionalWithPolymorphism
Jared