2009年6月3日星期三

Re: [fw-mvc] Pattern / example?

Hey Ed,

usually a Model's responsibility does not include how it's viewed (think of a PersonModel that appears in an XML dump, a JSON web service and on an HTML page). I would suggest writing a view helper that would accept a certain kind of model that implements a collection of properties / methods in an interface so that my view code could be handled by an object that would only have that concern.

Best,
-
Jon

On Wed, Jun 3, 2009 at 4:37 PM, Ed Lazor <edlazor@internetarchitects.biz> wrote:
Anyone happen to have their models designed to "render" themselves?
For example:

$model->display();

or

$model->draw();

This is more of a general OOP question, but I'd like to apply it as
much to ZF as possible since that's where I'll be implementing it.  I
read how you're supposed to design your objects and assign them the
responsibilities to manage themselves.  The article (mentioned in my
last thread) gave the example of having the model draw itself.  It
sounds neat, so I'd like to try it and I'm wondering how to approach
it.  I'm guessing the model would generate the data, send it to an
adapter of some sort, the adapter would apply a template (or
whatever), results would return to the model, which then returns the
results to the originating code.  Is that correct?  Anyone know / have
examples?

Thanks,

Ed

没有评论: