<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Sustainable Development in Ruby, Part 1: Good Old-Fashioned Inheritance</title>
	<link>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/</link>
	<description></description>
	<pubDate>Sat, 19 Jul 2008 20:23:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Enfranchised Mind &#187; 7 Actually Useful Things You Didn&#8217;t Know Static Typing Could Do: An Introduction for the Dynamic Language Enthusiast</title>
		<link>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-51</link>
		<dc:creator>Enfranchised Mind &#187; 7 Actually Useful Things You Didn&#8217;t Know Static Typing Could Do: An Introduction for the Dynamic Language Enthusiast</dc:creator>
		<pubDate>Mon, 14 Apr 2008 14:49:48 +0000</pubDate>
		<guid>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-51</guid>
		<description>[...] This is certainly a leap and a bound beyond global duck punching, where you need to know how every use of that module is going to behave, and then validate that it works out in all those cases. The reality in my experience is that people who pull off global duck punching tend to just kind of pray and hope their unit tests catch any bug they just introduced. This makes me unoptomistic about the maintainability of that code &#8212; and even the Ruby community is starting to agree with me (cite, cite). [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] This is certainly a leap and a bound beyond global duck punching, where you need to know how every use of that module is going to behave, and then validate that it works out in all those cases. The reality in my experience is that people who pull off global duck punching tend to just kind of pray and hope their unit tests catch any bug they just introduced. This makes me unoptomistic about the maintainability of that code &#8212; and even the Ruby community is starting to agree with me (cite, cite). [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: This Week in Ruby (April 7, 2008) &#124; Zen and the Art of Programming</title>
		<link>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-39</link>
		<dc:creator>This Week in Ruby (April 7, 2008) &#124; Zen and the Art of Programming</dc:creator>
		<pubDate>Mon, 07 Apr 2008 10:07:25 +0000</pubDate>
		<guid>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-39</guid>
		<description>[...] Development in Ruby (part 1 and part [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] Development in Ruby (part 1 and part [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Virtuous Code &#8250; Sustainable Development in Ruby, Part 2: Method Injection</title>
		<link>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-27</link>
		<dc:creator>Virtuous Code &#8250; Sustainable Development in Ruby, Part 2: Method Injection</dc:creator>
		<pubDate>Tue, 01 Apr 2008 02:00:12 +0000</pubDate>
		<guid>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-27</guid>
		<description>[...] fields are marked * Name *  Email *  Website  Comment   add_openid_to_comment_form()     &#8249; Sustainable Development in Ruby, Part 1: Good Old-Fashioned Inheritance      &#169; 2008   &#182; Thanks, WordPress. &#182; veryplaintxt theme by Scott Allan Wallick. [...]</description>
		<content:encoded><![CDATA[<p>[&#8230;] fields are marked * Name *  Email *  Website  Comment   add_openid_to_comment_form()     &lsaquo; Sustainable Development in Ruby, Part 1: Good Old-Fashioned Inheritance      &copy; 2008   &para; Thanks, WordPress. &para; veryplaintxt theme by Scott Allan Wallick. [&#8230;]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-26</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Sat, 29 Mar 2008 21:37:26 +0000</pubDate>
		<guid>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-26</guid>
		<description>Pat: I understand your point, but this was the inheritance post :-)  Composition will come later.</description>
		<content:encoded><![CDATA[<p>Pat: I understand your point, but this was the inheritance post <img src='http://avdi.org/devblog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Composition will come later.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pat Maddox</title>
		<link>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-25</link>
		<dc:creator>Pat Maddox</dc:creator>
		<pubDate>Sat, 29 Mar 2008 21:05:57 +0000</pubDate>
		<guid>http://avdi.org/devblog/2008/03/27/sustainable-development-in-ruby-part-1-good-old-fashioned-inheritance/#comment-25</guid>
		<description>I think this is a perfect example of where to prefer composition over inheritance.  I would probably do:

&lt;code&gt;class BufferedReader
  def initialize(connection)
    @connection = connection
  end
  
  def receive
    buffer = ""
    begin
      message = @connection.receive
      buffer &#60;&#60; message.data
    end until(message.data.include?("ENDENDEND"))
    Message.new(buffer)
  end
end&lt;/code&gt;

This allows you to combine different readers to achieve the behavior you want.  Not only that, but now the buffered reader is generally useful instead of being coupled to the Connection class.</description>
		<content:encoded><![CDATA[<p>I think this is a perfect example of where to prefer composition over inheritance.  I would probably do:</p>
<p><code>class BufferedReader<br />
  def initialize(connection)<br />
    @connection = connection<br />
  end</code></p>
<p>  def receive<br />
    buffer = &#8220;&#8221;<br />
    begin<br />
      message = @connection.receive<br />
      buffer &lt;&lt; message.data<br />
    end until(message.data.include?(&#8220;ENDENDEND&#8221;))<br />
    Message.new(buffer)<br />
  end<br />
end</p>
<p>This allows you to combine different readers to achieve the behavior you want.  Not only that, but now the buffered reader is generally useful instead of being coupled to the Connection class.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
