<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule"
	>
<channel>
	<title>Comments on: Sustainable Development in Ruby, Part 2: Method Injection</title>
	<atom:link href="http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/feed/" rel="self" type="application/rss+xml" />
	<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/</link>
	<description>"...the three great virtues of a programmer: laziness, impatience, and hubris." -- Larry Wall</description>
	<lastBuildDate>Wed, 03 Mar 2010 21:56:22 -0800</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jay</title>
		<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-245</link>
		<dc:creator>Jay</dc:creator>
		<pubDate>Tue, 03 Feb 2009 10:58:51 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-245</guid>
		<description>&lt;strong&gt;code reuse...&lt;/strong&gt;

You have got to be kidding!...</description>
		<content:encoded><![CDATA[<p><strong>code reuse&#8230;</strong></p>
<p>You have got to be kidding!&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: anonymous coward</title>
		<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-207</link>
		<dc:creator>anonymous coward</dc:creator>
		<pubDate>Wed, 07 Jan 2009 21:21:25 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-207</guid>
		<description>An alternative implementation of the same idea presented in this article is to create a module that has an :end? method and then extend the method with that module.  Extending objects with a module also addresses some of the performance concerns associated with creating a metaclass for each message.&lt;br&gt;&lt;br&gt;class BufferedConnection &lt; FMTP::Connection&lt;br&gt;  module Extension&lt;br&gt;    def end?&lt;br&gt;      data.inclue?(&#039;ENDENDEND&#039;)&lt;br&gt;    end&lt;br&gt;  end&lt;br&gt;&lt;br&gt;  def extend_message(message)&lt;br&gt;    message.extend(Extension)&lt;br&gt;  end&lt;br&gt;end&lt;br&gt;&lt;br&gt;With this implementation, perhaps it would be simpler to do extend the message inline rather than calling a method named extend_message with simply calls extend on the method:&lt;br&gt;   before:  message = extend_message(super)&lt;br&gt;   after:  message = super.extend(Extension) # and removal of the extend_message method</description>
		<content:encoded><![CDATA[<p>An alternative implementation of the same idea presented in this article is to create a module that has an :end? method and then extend the method with that module.  Extending objects with a module also addresses some of the performance concerns associated with creating a metaclass for each message.</p>
<p>class BufferedConnection &lt; <span class="caps">FMTP</span>::Connection<br />  module Extension<br />    def end?<br />      data.inclue?(&#39;ENDENDEND&#39;)<br />    end<br />  end</p>
<p>  def extend_message(message)<br />    message.extend(Extension)<br />  end<br />end</p>
<p>With this implementation, perhaps it would be simpler to do extend the message inline rather than calling a method named extend_message with simply calls extend on the method:<br />   before:  message = extend_message(super)<br />   after:  message = super.extend(Extension) # and removal of the extend_message method</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: poop</title>
		<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-182</link>
		<dc:creator>poop</dc:creator>
		<pubDate>Tue, 28 Oct 2008 21:12:00 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-182</guid>
		<description>It also has the advantage of still allowing the Message object and the class needing to use the end? functionality to still remain orthogonal to each other.&lt;br&gt;&lt;br&gt;I pity the man that upgrades the FMTP library only to find out that end? has been implemented and used there, and runs that code.</description>
		<content:encoded><![CDATA[<p>It also has the advantage of still allowing the Message object and the class needing to use the end? functionality to still remain orthogonal to each other.</p>
<p>I pity the man that upgrades the <span class="caps">FMTP </span>library only to find out that end? has been implemented and used there, and runs that code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Virtuous Code &#8250; Sustainable Development in Ruby Part 3: Delegation</title>
		<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-56</link>
		<dc:creator>Virtuous Code &#8250; Sustainable Development in Ruby Part 3: Delegation</dc:creator>
		<pubDate>Thu, 17 Apr 2008 20:46:31 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-56</guid>
		<description>[...] our last episode we were augmenting FMTP::Message classes to deal with messages split across multiple packets. As is [...]</description>
		<content:encoded><![CDATA[<p>[...] our last episode we were augmenting <span class="caps">FMTP</span>::Message classes to deal with messages split across multiple packets. As is [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-55</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Thu, 17 Apr 2008 16:16:42 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-55</guid>
		<description>Shalev:

1. To quote Knuth, premature optimization is the root of all evil ;-)  Considering that our mythical Flying Monkey Transport Protocol probably has a packet latency measured in hours, I suspect that this is the least of their performance problems.

2. See the introduction to this series.  If two separate pieces of code independently try to add the same method, it&#039;s no longer a method addition and becomes an inadvertent method redefinition.

3a. I apply &lt;a href=&quot;http://c2.com/xp/YouArentGonnaNeedIt.html&quot; rel=&quot;nofollow&quot;&gt;YAGNI&lt;/a&gt; pretty religiously.  I used to code based on the &quot;we&#039;ll need it someday&quot; principle a long time ago, and it never got me anywhere good.

3b. Reuse is not the only reason to extract code into a method.  Other reasons include readability and enforcing the Single Responsibility Principle.  The code that calls #end? is not concerned with how we know that the message is at the end, but with what to do if it is.  Having the implementation details of &lt;em&gt;how&lt;/em&gt; we know at that point is a distraction from the core purpose of the code.

But this kind of misses the point anyway, because this is demo code which I have deliberately kept simple in order to focus on the techniques being presented.  In the real world #end? might very well be a more complicated (and distracting) algorithm.</description>
		<content:encoded><![CDATA[<p>Shalev:</p>
<p>1. To quote Knuth, premature optimization is the root of all evil <img src='http://avdi.org/devblog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   Considering that our mythical Flying Monkey Transport Protocol probably has a packet latency measured in hours, I suspect that this is the least of their performance problems.</p>
<p>2. See the introduction to this series.  If two separate pieces of code independently try to add the same method, it&#8217;s no longer a method addition and becomes an inadvertent method redefinition.</p>
<p>3a. I apply <a href="http://c2.com/xp/YouArentGonnaNeedIt.html" rel="nofollow"><span class="caps">YAGNI</span></a> pretty religiously.  I used to code based on the &#8220;we&#8217;ll need it someday&#8221; principle a long time ago, and it never got me anywhere good.</p>
<p>3b. Reuse is not the only reason to extract code into a method.  Other reasons include readability and enforcing the Single Responsibility Principle.  The code that calls #end? is not concerned with how we know that the message is at the end, but with what to do if it is.  Having the implementation details of <em>how</em> we know at that point is a distraction from the core purpose of the code.</p>
<p>But this kind of misses the point anyway, because this is demo code which I have deliberately kept simple in order to focus on the techniques being presented.  In the real world #end? might very well be a more complicated (and distracting) algorithm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-144</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Thu, 17 Apr 2008 14:16:42 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-144</guid>
		<description>Shalev:&lt;br&gt;&lt;br&gt;1. To quote Knuth, premature optimization is the root of all evil ;-)  Considering that our mythical Flying Monkey Transport Protocol probably has a packet latency measured in hours, I suspect that this is the least of their performance problems.&lt;br&gt;&lt;br&gt;2. See the introduction to this series.  If two separate pieces of code independently try to add the same method, it&#039;s no longer a method addition and becomes an inadvertent method redefinition.&lt;br&gt;&lt;br&gt;3a. I apply &lt;a href=&quot;http://c2.com/xp/YouArentGonnaNeedIt.html&quot; rel=&quot;nofollow&quot;&gt;YAGNI&lt;/a&gt; pretty religiously.  I used to code based on the &quot;we&#039;ll need it someday&quot; principle a long time ago, and it never got me anywhere good.&lt;br&gt;&lt;br&gt;3b. Reuse is not the only reason to extract code into a method.  Other reasons include readability and enforcing the Single Responsibility Principle.  The code that calls #end? is not concerned with how we know that the message is at the end, but with what to do if it is.  Having the implementation details of &lt;em&gt;how&lt;/em&gt; we know at that point is a distraction from the core purpose of the code.&lt;br&gt;&lt;br&gt;But this kind of misses the point anyway, because this is demo code which I have deliberately kept simple in order to focus on the techniques being presented.  In the real world #end? might very well be a more complicated (and distracting) algorithm.</description>
		<content:encoded><![CDATA[<p>Shalev:</p>
<p>1. To quote Knuth, premature optimization is the root of all evil <img src='http://avdi.org/devblog/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />   Considering that our mythical Flying Monkey Transport Protocol probably has a packet latency measured in hours, I suspect that this is the least of their performance problems.</p>
<p>2. See the introduction to this series.  If two separate pieces of code independently try to add the same method, it&#39;s no longer a method addition and becomes an inadvertent method redefinition.</p>
<p>3a. I apply <a href="http://c2.com/xp/YouArentGonnaNeedIt.html" rel="nofollow"><span class="caps">YAGNI</span></a> pretty religiously.  I used to code based on the &#8220;we&#39;ll need it someday&#8221; principle a long time ago, and it never got me anywhere good.</p>
<p>3b. Reuse is not the only reason to extract code into a method.  Other reasons include readability and enforcing the Single Responsibility Principle.  The code that calls #end? is not concerned with how we know that the message is at the end, but with what to do if it is.  Having the implementation details of <em>how</em> we know at that point is a distraction from the core purpose of the code.</p>
<p>But this kind of misses the point anyway, because this is demo code which I have deliberately kept simple in order to focus on the techniques being presented.  In the real world #end? might very well be a more complicated (and distracting) algorithm.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shalev</title>
		<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-52</link>
		<dc:creator>Shalev</dc:creator>
		<pubDate>Tue, 15 Apr 2008 06:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-52</guid>
		<description>A few points:

1. This strikes me as fairly inefficient.  Assuming this receive loop works for a while, you&#039;ve just created a large number of objects and then dynamically defined a method on each one.

2. You state that &quot;adding an undefined method...is not without its risks,&quot; but you fail to state what those risks are.

3. &quot;we only need the #end? method in one place&quot;  This may be true now, but surely the method may be useful further down the line.  What&#039;s more, if this really is true, I don&#039;t see your logic for creating a special #end? method anyway.  message.data.include?(&quot;ENDENDEND&quot;) isn&#039;t a large statement and it has the added advantages of being clearer and more specific (without requiring someone reading your code to jump down to the #end? method to see what the end condition is.)  Normally you would move code into a method in order to reuse it.  If you&#039;re not going to do that, then there really isn&#039;t much of a point to creating a separate method.</description>
		<content:encoded><![CDATA[<p>A few points:</p>
<p>1. This strikes me as fairly inefficient.  Assuming this receive loop works for a while, you&#8217;ve just created a large number of objects and then dynamically defined a method on each one.</p>
<p>2. You state that &#8220;adding an undefined method&#8230;is not without its risks,&#8221; but you fail to state what those risks are.</p>
<p>3. &#8220;we only need the #end? method in one place&#8221;  This may be true now, but surely the method may be useful further down the line.  What&#8217;s more, if this really is true, I don&#8217;t see your logic for creating a special #end? method anyway.  message.data.include?(&#8221;ENDENDEND&#8221;) isn&#8217;t a large statement and it has the added advantages of being clearer and more specific (without requiring someone reading your code to jump down to the #end? method to see what the end condition is.)  Normally you would move code into a method in order to reuse it.  If you&#8217;re not going to do that, then there really isn&#8217;t much of a point to creating a separate method.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shalev</title>
		<link>http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-143</link>
		<dc:creator>Shalev</dc:creator>
		<pubDate>Tue, 15 Apr 2008 04:27:24 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-143</guid>
		<description>A few points:&lt;br&gt;&lt;br&gt;1. This strikes me as fairly inefficient.  Assuming this receive loop works for a while, you&#039;ve just created a large number of objects and then dynamically defined a method on each one.&lt;br&gt;&lt;br&gt;2. You state that &quot;adding an undefined method...is not without its risks,&quot; but you fail to state what those risks are.&lt;br&gt;&lt;br&gt;3. &quot;we only need the #end? method in one place&quot;  This may be true now, but surely the method may be useful further down the line.  What&#039;s more, if this really is true, I don&#039;t see your logic for creating a special #end? method anyway.  message.data.include?(&quot;ENDENDEND&quot;) isn&#039;t a large statement and it has the added advantages of being clearer and more specific (without requiring someone reading your code to jump down to the #end? method to see what the end condition is.)  Normally you would move code into a method in order to reuse it.  If you&#039;re not going to do that, then there really isn&#039;t much of a point to creating a separate method.</description>
		<content:encoded><![CDATA[<p>A few points:</p>
<p>1. This strikes me as fairly inefficient.  Assuming this receive loop works for a while, you&#39;ve just created a large number of objects and then dynamically defined a method on each one.</p>
<p>2. You state that &#8220;adding an undefined method&#8230;is not without its risks,&#8221; but you fail to state what those risks are.</p>
<p>3. &#8220;we only need the #end? method in one place&#8221;  This may be true now, but surely the method may be useful further down the line.  What&#39;s more, if this really is true, I don&#39;t see your logic for creating a special #end? method anyway.  message.data.include?(&#8221;ENDENDEND&#8221;) isn&#39;t a large statement and it has the added advantages of being clearer and more specific (without requiring someone reading your code to jump down to the #end? method to see what the end condition is.)  Normally you would move code into a method in order to reuse it.  If you&#39;re not going to do that, then there really isn&#39;t much of a point to creating a separate method.</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/31/sustainable-development-in-ruby-part-2-method-injection/comment-page-1/#comment-40</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:40 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/2008/03/31/sustainable-development-in-ruby-part-2-method-injection/#comment-40</guid>
		<description>[...] Sustainable Development in Ruby (part 1 and part 2) [...]</description>
		<content:encoded><![CDATA[<p>[...] Sustainable Development in Ruby (part 1 and part 2) [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.542 seconds -->
