<?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: Assertive Code</title>
	<atom:link href="http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/feed/" rel="self" type="application/rss+xml" />
	<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/</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: Ennuyer.net &#187; Blog Archive &#187; Rails Reading - November 24, 2009</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-779</link>
		<dc:creator>Ennuyer.net &#187; Blog Archive &#187; Rails Reading - November 24, 2009</dc:creator>
		<pubDate>Tue, 24 Nov 2009 22:44:44 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-779</guid>
		<description>[...]  Assertive Code &#124; Virtuous Code  [...]</description>
		<content:encoded><![CDATA[<p>[...]  Assertive Code | Virtuous Code  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Practical Programming: Holding the Flow of Code in Mind</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-773</link>
		<dc:creator>Practical Programming: Holding the Flow of Code in Mind</dc:creator>
		<pubDate>Sun, 22 Nov 2009 17:39:13 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-773</guid>
		<description>[...] Assertive Code (avdi.org) [...]</description>
		<content:encoded><![CDATA[<p>[...] Assertive Code (avdi.org) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-761</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Wed, 18 Nov 2009 16:57:30 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-761</guid>
		<description>I&#039;d also say that your example more brittle and in a more subtle way than mine. Supposing I&#039;m the maintainer of the superclass, and you maintain the subclass. One day, having no knowledge of your code, I decided that in the next release my superclass is going to use the &lt;code&gt;:caffeinated&lt;/code&gt; option internally.  The next time you update you have to figure out why your option isn&#039;t taking effect any more and I get a grumpy complaint from you that I&#039;ve appropriated &quot;your&quot; option.&lt;br&gt;&lt;br&gt;Much better to be courteous to superclasses and clean out subclass-specific stuff from the arguments before invoking them.</description>
		<content:encoded><![CDATA[<p>I&#39;d also say that your example more brittle and in a more subtle way than mine. Supposing I&#39;m the maintainer of the superclass, and you maintain the subclass. One day, having no knowledge of your code, I decided that in the next release my superclass is going to use the <code>:caffeinated</code> option internally.  The next time you update you have to figure out why your option isn&#39;t taking effect any more and I get a grumpy complaint from you that I&#39;ve appropriated &#8220;your&#8221; option.</p>
<p>Much better to be courteous to superclasses and clean out subclass-specific stuff from the arguments before invoking them.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-758</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Wed, 18 Nov 2009 16:42:46 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-758</guid>
		<description>I subclass and add new options all the time. It&#039;s just a matter of pulling out the added options &lt;em&gt;before&lt;/em&gt; calling &lt;code&gt;super&lt;/code&gt;. If for some reason you &lt;em&gt;must&lt;/em&gt; have the superclass initialized before processing the added options, pull the option out into a local before calling &lt;code&gt;super&lt;/code&gt; and then process it after.&lt;br&gt;&lt;br&gt;Your subclasses shouldn&#039;t be permitting values to get to the superclass constructor which they don&#039;t expect it to be able to handle.</description>
		<content:encoded><![CDATA[<p>I subclass and add new options all the time. It&#39;s just a matter of pulling out the added options <em>before</em> calling <code>super</code>. If for some reason you <em>must</em> have the superclass initialized before processing the added options, pull the option out into a local before calling <code>super</code> and then process it after.</p>
<p>Your subclasses shouldn&#39;t be permitting values to get to the superclass constructor which they don&#39;t expect it to be able to handle.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan Davis</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-757</link>
		<dc:creator>Ryan Davis</dc:creator>
		<pubDate>Wed, 18 Nov 2009 16:09:26 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-757</guid>
		<description>Trust, but verify? No. Can&#039;t people learn that Reagan was a moron? Just trust. That is the way of dynamic programming.&lt;br&gt;&lt;br&gt;Fail fast often takes care of itself, but if not, help it along. Just don&#039;t help it along like your examples show.&lt;br&gt;&lt;br&gt;Your #initialize example is static and brittle. If you subclass, you can&#039;t extend like so:&lt;br&gt;&lt;br&gt;    def initialize&lt;br&gt;      super&lt;br&gt;      &lt;br&gt;      # handle new option that depends on old options being processed.&lt;br&gt;      @uncaffeinated = options.delete(:caffeinated) { not_feeling_creative }  &lt;br&gt;    end</description>
		<content:encoded><![CDATA[<p>Trust, but verify? No. Can&#39;t people learn that Reagan was a moron? Just trust. That is the way of dynamic programming.</p>
<p>Fail fast often takes care of itself, but if not, help it along. Just don&#39;t help it along like your examples show.</p>
<p>Your #initialize example is static and brittle. If you subclass, you can&#39;t extend like so:</p>
<p>    def initialize<br />      super</p>
<p>      # handle new option that depends on old options being processed.<br />      @uncaffeinated = options.delete(:caffeinated) { not_feeling_creative }  <br />    end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-756</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Wed, 18 Nov 2009 16:02:43 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-756</guid>
		<description>Update: phiggy is correct. Looks like I was confusing instance_of?() with is_a?(). I&#039;ve updated the article accordingly.</description>
		<content:encoded><![CDATA[<p>Update: phiggy is correct. Looks like I was confusing instance_of?() with is_a?(). I&#39;ve updated the article accordingly.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-754</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Wed, 18 Nov 2009 15:59:13 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-754</guid>
		<description>That&#039;s a very good point - it gives you more confidence as a developer when you know that a value e.g. can&#039;t be nil beyond a certain point.</description>
		<content:encoded><![CDATA[<p>That&#39;s a very good point &#8211; it gives you more confidence as a developer when you know that a value e.g. can&#39;t be nil beyond a certain point.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-752</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Wed, 18 Nov 2009 15:58:05 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-752</guid>
		<description>Thanks, fixed.</description>
		<content:encoded><![CDATA[<p>Thanks, fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-753</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Wed, 18 Nov 2009 15:57:46 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-753</guid>
		<description>Good catch! Looks like I&#039;ve been confusing instance_of?() and is_a?()</description>
		<content:encoded><![CDATA[<p>Good catch! Looks like I&#39;ve been confusing instance_of?() and is_a?()</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: avdi</title>
		<link>http://avdi.org/devblog/2009/11/18/self-confidence-through-assertions/comment-page-1/#comment-751</link>
		<dc:creator>avdi</dc:creator>
		<pubDate>Wed, 18 Nov 2009 15:53:41 +0000</pubDate>
		<guid isPermaLink="false">http://avdi.org/devblog/?p=258#comment-751</guid>
		<description>kind_of?() asks if the receiver inherits the given class or module somewhere in its ancestor chain. is_a?() only returns true if the receiver is of &lt;em&gt;exactly&lt;/em&gt; that type - not a subcless. I almost never use is_a() for this reason - my code shouldn&#039;t break just because someone subclassed String.</description>
		<content:encoded><![CDATA[<p>kind_of?() asks if the receiver inherits the given class or module somewhere in its ancestor chain. is_a?() only returns true if the receiver is of <em>exactly</em> that type &#8211; not a subcless. I almost never use is_a() for this reason &#8211; my code shouldn&#39;t break just because someone subclassed String.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

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