Re: Your opinion about QuickForm2 API
| From: | Jandro brozaman | Date: | Mon, 16 Apr 2007 13:05:07 +0000 |
| Subject: | Re: Your opinion about QuickForm2 API | ||
| Groups: | php.pear.dev php.pear.general | ||
| Request: | Send a blank email to pear-dev+get-46238@lists.php.net to get a copy of this message | ||
My vote for Bertrand in both discussion.
----- Mensaje original ----
De: Bertrand Mansion <golgote@mamasam.com>
Para: PEAR Announce <pear-dev@lists.php.net>
CC: PEAR list general <pear-general@lists.php.net>
Enviado: lunes, 16 de abril, 2007 11:08:16
Asunto: [PEAR] Your opinion about QuickForm2 API
Hi all,
We are in the middle of a discussion Alexey and I about QuickForm2
API for elements creation and I would like your opinion as well.
At this point, nothing is immutable since we aren't even talking
about alpha stage, so your preferences as users and developers is
interesting.
To summarize, Alexey would be in favor of this:
$form->addElement('button', 'aButton', 'Click me please');
$form->addElement('select', 'aSelect', array('1' => 'option
1', '2'
=> 'option 2'));
While I would be in favor of this:
$form->addElement('button', 'aButton')->setContent('Click me
please');
$form->addElement('select', 'aSelect')->setOptions(array('1'
=>
'option 1', '2' => 'option 2'));
This is an example for adding a button to a form. The API can get
more complex for Date elements and other javascript aided elements.
My opinion is that we shouldn't mix configuration parameters for
elements with other kind of data they might need.
The other point we are discussing is about the extra parameter in
element creation. I suggest we always use an array, even when there
is only one extra parameter. Alexey suggests that we use a scalar if
there is only one extra parameter. For example, for a given "Year"
element which would only accept one configuration parameter
'startYear', Alexey would use:
$form->addElement('year', 'aYear', '2007');
While I would use:
$form->addElement('year', 'aYear', array('startYear' =>
'2007'));
So my way is more verbose and less writable, but is also more
readable and extensible.
Given these examples, are there any opinions or preferences in favor
of one or the other proposed API ?
Thanks in advance,
--
Bertrand Mansion
Mamasam
Work : http://www.mamasam.com
Blog : http://golgote.freeflux.net
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
____________________________________________________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com