Reply to Render yourself ou ask someone else to render you?

Your name:

Reply:


Posted by Vincent B on 10/23/70 11:34

Hi,

Here is a quick OO design question. Suppose I have a few objects that I
would want rendered in HTML (Article, Category). What would be the best
OO way to render them?

If I am not mistaken,

1) the Strategy pattern would instruct me to pass the rendering to
another object. So I would have HTMLArticleRenderer that is constructed
using an Article object and that will render using
HTMLArticleRenderer->render(). If I wanted to add a PDF output, I could
just add a PDFArticleRenderer and switch renderer at runtime.

2) the Decorator pattern would instruct me to add a render() method to
every object (Article, Category) so they could be called in a tree-like
fashion.

I want your opinion on which would be the best solution or the
cleanest?

Regards,

Vincent

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация