[Nitro] xhtml builder in model?
James Britt
james_b at neurogami.com
Wed Sep 7 00:42:50 EDT 2005
TRANS wrote:
> On 9/6/05, James Britt <james_b at neurogami.com> wrote:
...
>>No, I thin the idea is to be able to do something like this:
>>
>>my_model.render( pdf_writer )
>> or
>>my_model.render( wml_writer )
>>
>>where all *_writer objects expose a known API; my_model need only know
>>about that single API, passing data to the writer object. The writer
>>need not know the data details of my_model.
>
>
> But what does that amount to? Both writer's have to have the same API.
> That can be difficult, commonly resulting in an LCD effect. Even so,
> you've reduced the problem to a single interface writer->model, but
> it's a one-to-one mapping so you can turn it orthogonally and do
> model -> writer. It amounts to the same thing.
>
> class Writer
> def render( model )
> do_this(model.x)
> do_that(model.y)
>
> class Model
> def render( writer )
> writer.do_this(self.x)
> writer.do_that(self.y)
>
I don't know that I can offer a persuasive argument, but I prefer the
latter.
James
--
http://www.ruby-doc.org - The Ruby Documentation Site
http://www.rubyxml.com - News, Articles, and Listings for Ruby & XML
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
More information about the Nitro-general
mailing list