Re: common method names

From: Date: Thu, 06 Mar 2003 15:16:02 +0000
Subject: Re: common method names
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-14117@lists.php.net to get a copy of this message
On Wed, 2003-03-05 at 10:59, Bertrand Mansion wrote: > <wolfram@visionp.de> wrote : > > > i was just using HTML_TreeMenu and QuickForm > > and i realized that in TreeMenu you print the menu using > > $treeMenu->printMenu() > > but in QuickForm you need to use > > $form->display() > > > > should there not be a common name for both? > > i would suggest display() or toHtml() > > > > any comments? > > As you might guess, I am in favour of toHtml() when one need a string and > display() when one need this string echoed. ;) We used this scheme in > HTML_Table, HTML_Common, HTML_QuickForm and Config. Plus other methods like > toArray() from time to time. > > Have a nice day, You are assuming that the world runs on HTML. It doesn't :-) If there is a "toHtml" method, then "outputHtml" should simply print the return value. This way we also lay the foundation for something like "toXml" and "outputXml" for the cases where this would be interesting. Generally, I am more in favor of using the verb "display" or "show" rather than "output", since output is also a bit more web server/browser paradigm-bound. - Stig

« previous php.pear.dev (#14117) next »