[LRUG] Conditional Style (was: To debug the impossible bug)

Simon Coffey simon at tribesports.com
Wed Aug 3 06:29:45 PDT 2011


On 3 August 2011 13:55, Tom Stuart <tom at therye.org> wrote:
>
> Since we're all bamboozled by the bug and would rather discuss code style... ;)

Nice to have company, at least. :-)

> My preference is to favour polymorphism and have all the objects which a page can be about, implement a method providing that description, something like:
>
> class Question
>  def description_for_page
>    self.background
>  end
> end

I agree, eliminating the conditional with polymorphism would be hugely
preferable, but it feels a bit wrong putting view stuff in the
business logic. The other day I happened across[1] a project called
Draper (https://github.com/jcasimir/draper) that implements
Decorators/View-models for Rails apps, which looks interesting, and
might be the sort of thing to fill this gap. Haven't had a chance to
try it out yet, though.

Cheers,
Simon

[1] Via http://avdi.org/devblog/2011/07/27/fowler-on-rails/



More information about the Chat mailing list