|  | Posted by Vincent B on 06/13/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
  Navigation: [Reply to this message] |