<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>OLD Bamboo Blog - Latest Comments in Micro-patterns in Ruby</title><link>http://bambooblog.disqus.com/</link><description></description><atom:link href="https://bambooblog.disqus.com/micro_patterns_in_ruby/latest.rss" rel="self"></atom:link><language>en</language><lastBuildDate>Wed, 20 Feb 2008 13:33:00 -0000</lastBuildDate><item><title>Re: Micro-patterns in Ruby</title><link>http://blog.new-bamboo.co.uk/2008/02/05/micro-patterns-in-ruby#comment-5785014</link><description>&lt;p&gt;@Eric - No, self.instance is a class method, meant to be called on the class instead of an instance of that class.&lt;/p&gt;&lt;p&gt;SomeFactoryClass.instance( parameter) # =&amp;gt; some instance of some class&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ismael</dc:creator><pubDate>Wed, 20 Feb 2008 13:33:00 -0000</pubDate></item><item><title>Re: Micro-patterns in Ruby</title><link>http://blog.new-bamboo.co.uk/2008/02/05/micro-patterns-in-ruby#comment-5785015</link><description>&lt;p&gt;Under the comment:&lt;br&gt;# Refactored factory. No pun intended.&lt;br&gt;did you mean&lt;br&gt;def self.initialize(url)&lt;br&gt;instead of &lt;br&gt;def self.instance(url)&lt;br&gt;?&lt;/p&gt;&lt;p&gt;That threw me for a minute.&lt;br&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Eric</dc:creator><pubDate>Tue, 19 Feb 2008 14:40:00 -0000</pubDate></item><item><title>Re: Micro-patterns in Ruby</title><link>http://blog.new-bamboo.co.uk/2008/02/05/micro-patterns-in-ruby#comment-5785016</link><description>&lt;p&gt;Thanks for an interesting and informative post Ismael. It's seeing compact but expressive examples like this that makes ruby fun to learn. Keep it up!&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">PTL</dc:creator><pubDate>Thu, 14 Feb 2008 01:05:00 -0000</pubDate></item><item><title>Re: Micro-patterns in Ruby</title><link>http://blog.new-bamboo.co.uk/2008/02/05/micro-patterns-in-ruby#comment-5785019</link><description>&lt;p&gt;Hi Luke.&lt;br&gt;Yes, inheritance is probably misleading in my example, and it would certainly be an abuse if I was using ServiceParser only as a factory.&lt;/p&gt;&lt;p&gt;I actually based the examples on real code where ServiceParser has lots of private methods that are used by the subclasses. In my particular code, the parent class (ServiceParser) initializes with an instance of hPricot, which is available to all subclasses to use on their particular services, and some shared exception handling routines.&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Ismael</dc:creator><pubDate>Tue, 05 Feb 2008 13:00:00 -0000</pubDate></item><item><title>Re: Micro-patterns in Ruby</title><link>http://blog.new-bamboo.co.uk/2008/02/05/micro-patterns-in-ruby#comment-5785022</link><description>&lt;p&gt;OK, that didn't work - there doesn't seem to be any indication of whether you can use Textile or similar here so let's give HTML a bash:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;&lt;br&gt;class ServiceParser&lt;br&gt;  def register_adapter(url_matcher, adapter)&lt;br&gt;    @@adapters[url_matcher] = adapter&lt;br&gt;  end&lt;br&gt;end&lt;br&gt;&lt;br&gt;class FlickrAdapter&lt;br&gt;  # knows nothing about ServiceParser&lt;br&gt;end&lt;br&gt;&lt;/code&gt;&lt;/pre&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Luke Redpath</dc:creator><pubDate>Tue, 05 Feb 2008 11:35:00 -0000</pubDate></item><item><title>Re: Micro-patterns in Ruby</title><link>http://blog.new-bamboo.co.uk/2008/02/05/micro-patterns-in-ruby#comment-5785023</link><description>&lt;p&gt;I'm a bit puzzled as to why FlickrAdapter is a sub-class of ServiceParser. Aren't they two entirely different things? It seems like an abuse of inheritance merely to create the convenience of just calling register_url at the bottom of the adapter's definition. I would be more inclined to go with a more open interface:&lt;/p&gt;&lt;p&gt;class ServiceParser&lt;br&gt;  def register_adapter(url_matcher, adapter)&lt;br&gt;    @@adapters[url_matcher] = adapter&lt;br&gt;  end&lt;br&gt;end&lt;/p&gt;&lt;p&gt;class FlickrAdapter&lt;br&gt;  # knows nothing about ServiceParser&lt;br&gt;end&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Luke Redpath</dc:creator><pubDate>Tue, 05 Feb 2008 11:34:00 -0000</pubDate></item><item><title>Re: Micro-patterns in Ruby</title><link>http://blog.new-bamboo.co.uk/2008/02/05/micro-patterns-in-ruby#comment-5784830</link><description>&lt;p&gt;I'm a bit puzzled as to why FlickrAdapter is a sub-class of ServiceParser. Aren't they two entirely different things? It seems like an abuse of inheritance merely to create the convenience of just calling register_url at the bottom of the adapter's definition. I would be more inclined to go with a more open interface:&lt;/p&gt;&lt;p&gt;class ServiceParser&lt;br&gt;  def register_adapter(url_matcher, adapter)&lt;br&gt;    @@adapters[url_matcher] = adapter&lt;br&gt;  end&lt;br&gt;end&lt;/p&gt;&lt;p&gt;class FlickrAdapter&lt;br&gt;  # knows nothing about ServiceParser&lt;br&gt;end&lt;/p&gt;&lt;p&gt;&lt;/p&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Luke Redpath</dc:creator><pubDate>Tue, 05 Feb 2008 11:34:00 -0000</pubDate></item></channel></rss>