Re: common method names
| From: | Bertrand Mansion | Date: | Thu, 06 Mar 2003 15:45:41 +0000 |
| Subject: | Re: common method names | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-14119@lists.php.net to get a copy of this message | ||
<ssb@fast.no> wrote :
> 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 :-)
<html>world</html> ;)
> 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.
That's fine with me. I like toHtml(), toXml(), toArray()...
The display() method might take an argument to call the desired output
method... Maybe "print" because "output" seems too vague ?
Bertrand Mansion
Mamasam