<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Mousetrap 2.0</title>
	<atom:link href="http://mousetrap2.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://mousetrap2.wordpress.com</link>
	<description>Building A Better Web</description>
	<lastBuildDate>Fri, 07 Mar 2008 18:28:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='mousetrap2.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Mousetrap 2.0</title>
		<link>http://mousetrap2.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://mousetrap2.wordpress.com/osd.xml" title="Mousetrap 2.0" />
	<atom:link rel='hub' href='http://mousetrap2.wordpress.com/?pushpress=hub'/>
		<item>
		<title>This Blog Has Moved</title>
		<link>http://mousetrap2.wordpress.com/2008/03/07/this-blog-has-moved/</link>
		<comments>http://mousetrap2.wordpress.com/2008/03/07/this-blog-has-moved/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 18:27:47 +0000</pubDate>
		<dc:creator>dyoder67</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://mousetrap2.wordpress.com/2008/03/07/this-blog-has-moved/</guid>
		<description><![CDATA[It was only here, for like, two days, but somehow it is showing up in search results and people are visiting. The real blog is here: http://dev.zeraweb.com/blog/mousetrap-2 Thanks! <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mousetrap2.wordpress.com&amp;blog=2116750&amp;post=8&amp;subd=mousetrap2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>It was only here, for like, two days, but somehow it is showing up in search results and people are visiting. The real blog is here: <a href="http://dev.zeraweb.com/blog/mousetrap-2 ">http://dev.zeraweb.com/blog/mousetrap-2 </a>Thanks! </p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mousetrap2.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mousetrap2.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mousetrap2.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mousetrap2.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mousetrap2.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mousetrap2.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mousetrap2.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mousetrap2.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mousetrap2.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mousetrap2.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mousetrap2.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mousetrap2.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mousetrap2.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mousetrap2.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mousetrap2.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mousetrap2.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mousetrap2.wordpress.com&amp;blog=2116750&amp;post=8&amp;subd=mousetrap2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mousetrap2.wordpress.com/2008/03/07/this-blog-has-moved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/44869413a67ee5dc2d7d36533d055ecd?s=96&#38;d=identicon" medium="image">
			<media:title type="html">dyoder67</media:title>
		</media:content>
	</item>
		<item>
		<title>Site And Blog Reorg</title>
		<link>http://mousetrap2.wordpress.com/2007/11/13/site-and-blog-reorg/</link>
		<comments>http://mousetrap2.wordpress.com/2007/11/13/site-and-blog-reorg/#comments</comments>
		<pubDate>Tue, 13 Nov 2007 22:50:50 +0000</pubDate>
		<dc:creator>dyoder67</dc:creator>
				<category><![CDATA[Web Site]]></category>
		<category><![CDATA[blog]]></category>

		<guid isPermaLink="false">http://mousetrap2.wordpress.com/2007/11/13/site-and-blog-reorg/</guid>
		<description><![CDATA[We are moving our open source projects to Google Code, the Web site and blog to WordPress, and preparing for the release of and / or updates to several major open source initiatives. Expect an initial announcement later this week on the first of these projects. Our Web publishing service is not going away &#8211; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mousetrap2.wordpress.com&amp;blog=2116750&amp;post=5&amp;subd=mousetrap2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We are moving our open source projects to Google Code, the Web site and blog to WordPress, and preparing for the release of and / or updates to several major open source initiatives. Expect an initial announcement later this week on the first of these projects.</p>
<p>Our Web publishing service is not going away &#8211; it is still under active development and, in fact, we are more excited than ever about the next release. However,  our own requirements are better met by existing services (like Google Code), which also help to reduce the load on our servers.</p>
<p>Some (almost all) of the blog entries have disappeared. I plan to revise and re-post some of them; others will become wiki articles on Google Code; still others will disappear forever. In the end, nothing of interest will be lost and we will have a better foundation for future releases and announcements.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mousetrap2.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mousetrap2.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mousetrap2.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mousetrap2.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mousetrap2.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mousetrap2.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mousetrap2.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mousetrap2.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mousetrap2.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mousetrap2.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mousetrap2.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mousetrap2.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mousetrap2.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mousetrap2.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mousetrap2.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mousetrap2.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mousetrap2.wordpress.com&amp;blog=2116750&amp;post=5&amp;subd=mousetrap2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mousetrap2.wordpress.com/2007/11/13/site-and-blog-reorg/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/44869413a67ee5dc2d7d36533d055ecd?s=96&#38;d=identicon" medium="image">
			<media:title type="html">dyoder67</media:title>
		</media:content>
	</item>
		<item>
		<title>Top 10 Reasons To Avoid Component Libraries</title>
		<link>http://mousetrap2.wordpress.com/2007/05/18/top-10-reasons-to-avoid-component-libraries/</link>
		<comments>http://mousetrap2.wordpress.com/2007/05/18/top-10-reasons-to-avoid-component-libraries/#comments</comments>
		<pubDate>Fri, 18 May 2007 08:00:45 +0000</pubDate>
		<dc:creator>dyoder67</dc:creator>
				<category><![CDATA[JavaScript Frameworks]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[library]]></category>
		<category><![CDATA[top 10]]></category>

		<guid isPermaLink="false">http://mousetrap2.wordpress.com/2007/11/13/top-10-reasons-to-avoid-component-libraries/</guid>
		<description><![CDATA[An interesting commentary over at Ajaxian concerning the proliferation of component libraries (YUI, TIBCO, etc. ):

    Sometimes I feel a little bad when people enjoy a new component here or there, when there are tools such as TIBCO, Backbase, and Oracle ADF that have hundreds of them :)

Well, here are 10 reasons why Dion shouldn’t feel bad. :)<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mousetrap2.wordpress.com&amp;blog=2116750&amp;post=3&amp;subd=mousetrap2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>An <a href="http://ajaxian.com/archives/adf-faces-rich-client-components-demo">interesting commentary</a> over at <a href="http://ajaxian.com/">Ajaxian</a> concerning the proliferation of component libraries (YUI, <span class="caps">TIBCO</span>, etc. ):</p>
<blockquote>
<p class="quote">Sometimes I feel a little bad when people enjoy a new component here or there, when there are tools such as <span class="caps">TIBCO</span>, Backbase, and Oracle <span class="caps">ADF</span> that have hundreds of them :)</p>
</blockquote>
<p>Well, here are 10 reasons why Dion shouldn’t feel bad. :)</p>
<ol>
<li><strong>HTML is better than proprietary markup.</strong> That is especially true when the proprietary markup is in <span class="caps">XML</span>, which it almost always is … some of us want markup that describes the interface with libraries that just “hook” into it via <span class="caps">CSS</span> and / or some well-defined structure.</li>
<li><strong>My handpicked components load and run faster.</strong> Some of these libraries include, as Dion says, hundreds of components. It isn’t always easy to “trim the fat” and get rid of what you don’t need. In addition, the quality of the implementation may vary, particularly in terms of performance. Sorry, I need my page to load fast even over a shaky <span class="caps">DSL</span> connection.</li>
<li><strong>Desktop UIs are so 90s.</strong> We don’t need to keep trying to make the Web look like the desktop apps. Many of the Web UI idioms that are emerging are far superior to those on the desktop anyway. Let’s keep moving forwards, not trying to go back to the past.</li>
<li><strong>I don’t want your <span class="caps">IDE</span>.</strong> I have my own already. Thanks for using Eclipse, that’s better than making us use some completely proprietary <span class="caps">IDE</span>, but not all of us use Eclipse, either (TextMate, anyone?). Sorry. Bottom line: if using your libraries successfully depends on an <span class="caps">IDE</span>, that’s a problem.</li>
<li><strong>I don’t need a drag-and-drop <span class="caps">GUI</span> builder.</strong> That’s overkill. I’ve been doing <span class="caps">HTML</span> for years. It’s relatively simple and I generate most of it anyway from templates. I just want to describe my UI and let your library step in where its needed (see above). It’s called being nonintrusive.</li>
<li><strong>KISS still applies to Web apps.</strong> Some Web apps really do need a super auto sorting filtering live editing grid. Most don’t. Sometimes it is better to provide a simple list with a couple of obvious options for editing it. Note how successful Web apps (see Flickr, YouTube, et al) usually follow this approach.</li>
<li><strong>Web development idioms aren’t baked yet.</strong> Sometimes I think actually we’re just getting started. Some libraries have a great design that follows current best practices (see <a href="http://prototypejs.org/">Prototype</a>), while others are already outdated before they’re even released. Selectors are a great example of this. Selectors have become a powerful way to bind objects and events to <span class="caps">HTML</span> with the (quite recent) availability of fast <span class="caps">CSS3</span> implementations. That dramatically changes the best practices for interacting with the <span class="caps">DOM</span>.</li>
<li><strong>”It’s very nice, but we already got one.”</strong> I not only don’t need all of your components, but I may not want some of your “core” code. Selectors are again a great example. I’m quite happy with Prototype’s selector implementation. I don’t want to load a second one, but I can’t take yours out without breaking everything.</li>
<li><strong>Standards-based is good.</strong> Thanks for wanting to save me from <span class="caps">HTML</span>, CSS, and JavaScript, but I kind of like the fact that the code I write depends only on the community’s continued support of widely adopted standards. For all I know, you may decide that Web apps aren’t quite so important to you anymore a year or two down the road. Sure, maybe you’ve open-sourced the code, but without you, who keeps the platform moving forward?</li>
<li><strong>You still don’t have a <span class="caps">WYSIWYG HTML</span> editor.</strong> Pretty much anything you can do, I can do better (with the help of the many talented open source component authors out there). But there are a few things you probably <em>could</em> do better, but you don’t. So why do I care?</li>
</ol>
<p>Is there any component library out there that can say that even seven out of ten of these don’t apply? I’d like to know. I admit, I haven’t looked at each one in detail. After awhile, you get a bit cynical. And you never know when a new release might take a quantum leap. But, for now, I think I’m on pretty sure ground.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mousetrap2.wordpress.com/3/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mousetrap2.wordpress.com/3/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mousetrap2.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mousetrap2.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mousetrap2.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mousetrap2.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mousetrap2.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mousetrap2.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mousetrap2.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mousetrap2.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mousetrap2.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mousetrap2.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mousetrap2.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mousetrap2.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mousetrap2.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mousetrap2.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mousetrap2.wordpress.com&amp;blog=2116750&amp;post=3&amp;subd=mousetrap2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mousetrap2.wordpress.com/2007/05/18/top-10-reasons-to-avoid-component-libraries/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/44869413a67ee5dc2d7d36533d055ecd?s=96&#38;d=identicon" medium="image">
			<media:title type="html">dyoder67</media:title>
		</media:content>
	</item>
		<item>
		<title>Ruby Meta-Programming Gotchas</title>
		<link>http://mousetrap2.wordpress.com/2007/05/16/ruby-meta-programming-gotchas/</link>
		<comments>http://mousetrap2.wordpress.com/2007/05/16/ruby-meta-programming-gotchas/#comments</comments>
		<pubDate>Thu, 17 May 2007 00:49:11 +0000</pubDate>
		<dc:creator>dyoder67</dc:creator>
				<category><![CDATA[Ruby Programming]]></category>
		<category><![CDATA[meta-programming]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://mousetrap2.wordpress.com/2007/05/16/ruby-meta-programming-gotchas/</guid>
		<description><![CDATA[One of the neat features of Ruby is its support for meta-programming. That is code that, essentially, writes code. For example, my Rails ApplicationController has a method called instance, which uses the model name to return an instance variable using instance_variable_get, like this: def instance instance_variable_get "@#{model_name}"end Another powerful technique is the use of method_missing [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mousetrap2.wordpress.com&amp;blog=2116750&amp;post=7&amp;subd=mousetrap2&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>One of the neat features of Ruby is its support for meta-programming. That is code that, essentially, writes code. For example, my Rails <code>ApplicationController</code> has a method called <code>instance</code>, which uses the model name to return an instance variable using <code>instance_variable_get</code>, like this:
<pre><code>def instance  instance_variable_get "@#{model_name}"end</code></pre>
<p>Another powerful technique is the use of <code>method_missing</code> (which I always want to call <code>missing_method</code> for some reason). Rails itself uses this to implicitly add getters and setters for model instance’s attributes.<br />
<h2>Danger, Will Robinson!</h2>
<p>However, like any powerful feature, there are some dangers that go along with using these techniques. A couple of the more obvious ones:
<ul>
<li><strong>Bypassing <code>private</code> and <code>protected</code>.</strong> Ruby has an interesting approach when it comes to meta-programming: it assumes that if you know enough to use these kind of features, you don’t need the programming language to protect you from yourself. By definition, <code>instance_variable_get</code> gives you access to private data. Another method, <code>send</code> gives you access to private methods. This can have some interesting side-effects, as we’ll see below.</li>
</ul>
<ul>
<li><strong>Unexpected invocation of <code>method_missing</code>.</strong> Defining <code>method_missing</code> means that erroneous method invocations will now simply invoke your <code>method_missing</code>. This can lead to strange bugs and infinite loops. For example, from within the class that defines <code>method_missing</code>, even a reference to an undefined local variable can invoke <code>method_missing</code>, since Ruby thinks it might be a method invocation.</li>
</ul>
<h2>But Dan, What Can I Do?</h2>
<p>The number one rule about these methods is probably <em>don’t use them unless you have to</em>! However, that’s not much fun, since arguably you never really <em>have</em> to. I coded in <code>C++</code> for years and did just fine for the most part, and <code>C++</code> could not play these kinds of tricks – and least not easily. But one of the things that the Rails folks have reminded us about is that there is nothing wrong with wanting to enjoy what you do. And meta-programming is fun.So, having decided that we will use <code>missing_method</code> or <code>method_missing</code> or whatever it is, what can we do to keep from hurting ourselves? Here are a couple of handy little rules:<strong>Don’t use meta-programming to access private or protected data.</strong> Generally, if you are doing this, you are breaking the interface to the class. If you want to add to the interface, re-open the class definition and add the necessary accessors or whatever. At least that way you aren’t violating the encapsulation of the class.
<ul></ul>
<p>In the example above, <code>instance</code> is defined on the controller. The <code>instance_variable_get</code> method is being used entirely because it provides a simple way to access the “instance” of the controller without knowing what the instance variable name is, since it varies from controller to controller. Notice that this, in turn, makes it possible for other methods to access the instance variable for the controller without using <code>instance_variable_get</code>.<strong>Save <code>method_missing</code> for last.</strong> There is nothing wrong with implementing a method like <code>get_dynamic_attribute</code> or something like that, and then later, once you have the kinks worked out, changing it to <code>method_missing</code>. That way, while you are debugging, you don’t accidentally invoke <code>method_missing</code> and confuse things. Also, you might find that it actually makes more sense to have an explicit interface for such a method. And, after all that, if you still feel like <code>method_missing</code> improves your interface, you can add it quite easily, like this:
<ul></ul>
<pre><code>def method_missing(method,*args)  get_dynamic_attribute(method,*args)end</code></pre>
<p><strong>Use <code>super</code> in <code>method_missing</code>.</strong> <code>method_missing</code> allows you to implicitly define methods on a class. However, it also gets invoked even for methods you didn’t intend to define. In those cases, you need to pass along <code>method_missing</code> to the superclass. For example, Rails does this in ActiveRecord objects if you invoke a method that is not actually an attribute of the class. That way, the programmer still gets a missing method exception if they attempt to access a method that you never wanted to define, instead of some mysterious error that might not even make sense to you.
<ul></ul>
<p>Which means the above wrapper code should really look like this:
<pre><code>def method_missing(method,*args)  get_dynamic_attribute(method,*args) rescue superend</code></pre>
<p><strong>Don’t use <code>send</code> and <code>missing_method</code> together.</strong> More on this below.
<ul></ul>
<h2>Send Buddhism</h2>
<p>Let’s examine one of the mysteries of <code>send</code>. Actually, it isn’t really a mystery of <code>send</code> so much as <code>Object</code>. As I mentioned above, <code>send</code> bypasses private / protected distinctions – you can invoke <em>any</em> method on an object using <code>send</code>. This is very consistent with other meta-programming methods in Ruby. What makes this interesting is that there are a lot of methods defined on <code>Object</code> as private methods. They get pulled in from <code>Kernel</code> and, because they are private, they are easy to overlook. In fact, it is this bit of magic that allows you to use <code>Kernel</code> methods, like <code>puts</code> without referencing an <code>Object</code>.Here is a quick <code>irb</code> session that demonstrates what I’m talking about here:
<pre><code>irb(main):002:0&gt; class Foo ; end=&gt; nilirb(main):003:0&gt; Foo.new.puts "hello"NoMethodError: private method `puts' called for #        from (irb):3irb(main):004:0&gt; Foo.new.send :puts, "hello"hello=&gt; nil</code></pre>
<p>However, what this means is that when you use <code>send</code>, you have to remember that <em>all these methods become part of the interface</em>. There are a lot of these and so the interface may not be what you expect it to be when using <code>send</code>. In combination with other meta-programming techniques, including the use of <code>missing_method</code>, this can lead to very unexpected results.<br />
<h2><code>method_not_missing</code></h2>
<p>This can come up quite naturally. For example, suppose you want to parse a template that gives you access to an ActiveRecord attribute. You get the name of the attribute and naturally decide to use <code>send</code> to invoke the accessor. However, the accessor happens to be named “display”. Guess what? Instead of the ActiveRecord object’s <code>missing_method</code> (as he corrects himself for the 17th time in this blog entry after writing <code>method_missing</code>), you will get <code>Object#display</code>, which will quietly print the object on standard out and return nil.To your template parsing code, it looks as though the value of the <code>display</code> attribute is nil, when in fact, you have no idea what the value might be. There is no error or exception, either, and you’d have to look closely at your logs to see that anything at all was happening out of the ordinary. This is the kind of bug you can have nightmares about years later.This is another benefit to having an explicit interface for the implicit methods. Then, instead of using <code>send</code>, you can use that method. This is a flaw, in my opinion, of the current ActiveRecord implementation. An improved version would explicitly provide an accessor function in place of the current <code>method_missing</code>, and then simply have <code>method_missing</code> invoke that function, catching any exceptions and calling super.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/mousetrap2.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/mousetrap2.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/mousetrap2.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/mousetrap2.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/mousetrap2.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/mousetrap2.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/mousetrap2.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/mousetrap2.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/mousetrap2.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/mousetrap2.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/mousetrap2.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/mousetrap2.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/mousetrap2.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/mousetrap2.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/mousetrap2.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/mousetrap2.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=mousetrap2.wordpress.com&amp;blog=2116750&amp;post=7&amp;subd=mousetrap2&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://mousetrap2.wordpress.com/2007/05/16/ruby-meta-programming-gotchas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/44869413a67ee5dc2d7d36533d055ecd?s=96&#38;d=identicon" medium="image">
			<media:title type="html">dyoder67</media:title>
		</media:content>
	</item>
	</channel>
</rss>
