Re: function call chaining
| From: | Daniel Convissor | Date: | Wed, 20 Jan 2010 04:08:13 +0000 |
| Subject: | Re: function call chaining | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-46832@lists.php.net to get a copy of this message | ||
Hi Stas:
On Tue, Jan 19, 2010 at 12:09:53PM -0800, Stanislav Malyshev wrote:
>
> $oop = $eep->oop();
> $ork = $oop->ork();
> $ah = $ork->ah();
> $ah2 = $ah->ah();
>
> where it instantly becomes crystal clear!
:) Yep, that's lousy code.
Variables should be named for the classes they represent.
$eep = new eep;
$eep->oop();
$decorator = $eep->ork();
$decorator->ah();
$decorator->ah();
// Output, of course, is "I love you".
// What do you mean you've never seen The Jetsons?!
Now it's clear that oop() is a method of eep while ork returns a
decorator object that contains the ah() method. No guess work involved.
If everything is chained, it's a pain to figure out such basic workings.
I'll leave it at this.
Thanks,
--Dan
--
T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y
data intensive web and database programming
http://www.AnalysisAndSolutions.com/
4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409