Re: MVCnPHP
| From: | Tony Bibbs | Date: | Tue, 08 Apr 2003 13:01:29 +0000 |
| Subject: | Re: MVCnPHP | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-15022@lists.php.net to get a copy of this message | ||
On Tue, 8 Apr 2003, Jeroen Houben wrote:
> Hi Tony,
>
> I'm playing around with your example, just trying out different things.
> I'm trying to "upgrade" the example by incorporating PEAR::DataObject,
> PEAR::QuickForm and (in a next phase) Smarty.
Great!
>
> My first question is why you perform SQL SELECT queries is the
> Contact_View class. I understand it's just a small example so perhaps
> you did it just to simplify things, but shouldn't data fetching be part
> of a Model class?
Not really. I do envision updates to the database in a models class but
simple retrieves are OK IMHO. If this were a *real* application I might
create data access objects for the retrieval.
>
> Second question is: how would I make good use of QuickForm in this
> example? Quickform deals with display (View), but also with validation
> (Model, right?), which is a seperate class in your example. I'm not too
> sure where an instance of Quickform would fit as it serves both
> displaying purposes and validation purposes. Would it make sense to have
> some sort of Contact base class, which has an instance of QuickForm as a
> property and then have a Contact_Validate and a Contact_view class that
> both extend the Contact base class? Simplified it would look a little
> like this:
>
> Class Contact {
> var $_form;
> }
>
> Class Contact_Validate extends Contact {
> function validate() {
> return $this->_form->validate();
> }
> }
>
> Class Contact_View {
> function getView() {
> return $this->_form->toHtml(); // or $this->_form->display();
> }
> }
>
> Would that make sense?
Ok, first let me start by noting I don't have much experience yet with
QuickForm but have heard good things and I think having you integreate
QuickForm would be a great way to validate the usefulness of this MVC
package.
What you are proposing makes sense. Essentially you trying to move the
validation back into the form (which is how Struts handles it). Give me
some time to look at QuickForm and I'll get back to you
--
Tony Bibbs "I guess you have to remember that those who don't
tony@tonybibbs.com hunt or fish often see those of us who do as
harmlessly strange and sort of amusing. When you
think about it, that might be a fair assessment."
--Unknown