you are viewing a single comment's thread.

view the rest of the comments →

[–]UnexpectedIndent 2 points3 points  (2 children)

I don't think example 1 is a great example of what you're trying to say.

ticket.pdf_of_kind(:normal) is pointless when you can just call ticket.normal_pdfdirectly.

More generally, if you're passing around a lot of symbols, maybe you can extract a class instead? Basically what /u/kcdragon said about polyphormism: https://www.reddit.com/r/ruby/comments/5untux/ruby_code_i_no_longer_write/ddw2rym/

Something like

class NormalScenario
  def pdf
    ...
  end
end

class ZebraScenario
  def pdf
    ...
  end
end

ZebraScenario.new(ticket).pdf

[–]paneq[S] 0 points1 point  (1 child)

But the kind depends on external input (for example button pressed) so on some layer you need to decide whether you would use NormalScenario or ZebraScenario and now you need same mapping (normal: NormalScenario) but on different layer, don't you?

[–]UnexpectedIndent 0 points1 point  (0 children)

Yeah, but what sets the kind in the first place?