Re: Template Method Pattern (GoF) without abstract methods in Ruby
Greg Navis <[email protected]>
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <CAA6WWt8_ohXU49_Cx2rfbrM3bvNkSA4TddN55w8dh28HB=yAng@mail.gmail.com> |
I personally do add "abstract" methods that raise errors. It makes things more explicit than having being thrown NoMethodError in case I forget to implement it and makes it simple to identify which methods I need to implement/override in subclasses. I haven't seen your code but assuming the data structures representing the report are traversed the same for all formats you have two options: 1. Use the template method pattern as you said. 2. Make a ReportGenerator class that accepts ReportRenderer as an argument. It's difficult to say more without seeing the code though. Greg Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>