<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-294680397865315179.post1725024336631640560..comments</id><updated>2010-11-11T16:42:50.249-06:00</updated><category term='Plugins'/><category term='Static Typing'/><category term='3D modeling'/><category term='web'/><category term='UI'/><category term='hosting'/><category term='Windows'/><category term='iteration'/><category term='ASP.NET'/><category term='Environment'/><category term='cool stuff'/><category term='Customer Service'/><category term='ergonomics'/><category term='code coverage'/><category term='git'/><category term='Mac'/><category term='performance'/><category term='training'/><category term='coding discipline'/><category term='Dynamic Typing'/><category term='startups'/><category term='scripting'/><category term='Enterprise Development'/><category term='IE7'/><category term='Time Management'/><category term='SMS'/><category term='business'/><category term='CSS'/><category term='java'/><category term='refactoring'/><category term='Images'/><category term='Rails'/><category term='Arc'/><category term='rants'/><category term='college'/><category term='philosophy'/><category term='Best Practices'/><category term='employment'/><category term='twelve-hour'/><category term='Development Practices'/><category term='tutorials'/><category term='software'/><category term='Cron'/><category term='HTML'/><category term='voice recognition'/><category term='NHibernate'/><category term='RCov'/><category term='fun'/><category term='testing'/><category term='RTP'/><category term='gotcha'/><category term='svn'/><category term='recursion'/><category term='.NET'/><category term='users'/><category term='Analytics'/><category term='education'/><category term='Twitter'/><category term='Microsoft'/><category term='javascript'/><category term='Rails 2.2'/><category term='iTunesU'/><category term='Error Notification'/><category term='Security'/><category term='Lisp'/><category term='Sales'/><category term='source version control'/><category term='Blackberry'/><category term='consulting'/><category term='Centurytel'/><category term='Zetassociates'/><category term='code'/><category term='Rake'/><category term='debug'/><category term='other'/><category term='personal'/><category term='REST'/><category term='Office'/><category term='BackgroundJob'/><category term='IMAP'/><category term='Rails Source'/><category term='DB4O'/><category term='monitoring'/><category term='Rails 2.1'/><category term='service review'/><category term='Generics'/><category term='web services'/><category term='Algorithms'/><category term='hackers'/><category term='Google'/><category term='code reading'/><category term='Blogging'/><category term='life'/><category term='C#'/><category term='named_scope'/><category term='Open-source'/><category term='infrastructure'/><category term='mobile development'/><category term='Ruby'/><category term='Database'/><category term='administration'/><category term='languages'/><category term='investment'/><category term='Tools'/><category term='Hardware'/><category term='career'/><category term='Hoptoad'/><category term='Books'/><title type='text'>Comments on Ethan's Software Blog: The options Hash, a classic ruby pattern</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.ethanvizitei.com/feeds/1725024336631640560/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default'/><link rel='alternate' type='text/html' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html'/><author><name>Ethan Vizitei</name><uri>http://www.blogger.com/profile/16886242271824345907</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_vTrR73WnSs8/R41ZdF_kUeI/AAAAAAAAAqU/7ZbY4unHkXs/S220/me_with_glasses.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>5</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-294680397865315179.post-6867213671734130422</id><published>2010-11-07T13:03:09.758-06:00</published><updated>2010-11-07T13:03:09.758-06:00</updated><title type='text'>@Robert

I think I like your version best out of w...</title><content type='html'>@Robert&lt;br /&gt;&lt;br /&gt;I think I like your version best out of what&amp;#39;s on the page so far.  Defaults are declared in one place, but in context of the method.  Those Rails guys know what they&amp;#39;re doing. :)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/6867213671734130422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/6867213671734130422'/><link rel='alternate' type='text/html' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html?showComment=1289156589758#c6867213671734130422' title=''/><author><name>Ethan Vizitei</name><uri>http://www.blogger.com/profile/16886242271824345907</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_vTrR73WnSs8/R41ZdF_kUeI/AAAAAAAAAqU/7ZbY4unHkXs/S220/me_with_glasses.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html' ref='tag:blogger.com,1999:blog-294680397865315179.post-1725024336631640560' source='http://www.blogger.com/feeds/294680397865315179/posts/default/1725024336631640560' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1211555502'/></entry><entry><id>tag:blogger.com,1999:blog-294680397865315179.post-1138165485807034969</id><published>2010-11-07T10:56:45.499-06:00</published><updated>2010-11-07T10:56:45.499-06:00</updated><title type='text'>Rails usually does it this way:

def method(option...</title><content type='html'>Rails usually does it this way:&lt;br /&gt;&lt;br /&gt;def method(options={})&lt;br /&gt;  options.reverse_merge!(:volume =&amp;gt; 10)&lt;br /&gt;  ring(options)&lt;br /&gt;end</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/1138165485807034969'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/1138165485807034969'/><link rel='alternate' type='text/html' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html?showComment=1289149005499#c1138165485807034969' title=''/><author><name>Robert Pankowecki</name><uri>http://www.blogger.com/profile/12184851552948670848</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html' ref='tag:blogger.com,1999:blog-294680397865315179.post-1725024336631640560' source='http://www.blogger.com/feeds/294680397865315179/posts/default/1725024336631640560' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-2042416936'/></entry><entry><id>tag:blogger.com,1999:blog-294680397865315179.post-4040698101945215484</id><published>2010-11-04T13:05:55.289-05:00</published><updated>2010-11-04T13:05:55.289-05:00</updated><title type='text'>@first_Anonymous

I like that approach, although I...</title><content type='html'>@first_Anonymous&lt;br /&gt;&lt;br /&gt;I like that approach, although I haven&amp;#39;t used it myself.  The only thing that might make me think for a minute about not using it is that I habitually avoid instance variables if possible, but in this case since the only thing that references it is the defaults method, it&amp;#39;s really not a &amp;quot;risky&amp;quot; imposition on an otherwise functional process.  I may refactor some of my current code to do it this way to see how I like it, thanks for the comment!&lt;br /&gt;&lt;br /&gt;@second_Anonymous&lt;br /&gt;&lt;br /&gt;What I mean is that instead of calling &amp;quot;ring!&amp;quot; in each branch of the conditional,  you could do something like this:&lt;br /&gt;&lt;br /&gt;opts = {:volume=&amp;gt;3}&lt;br /&gt;if caller.is_my_friend?&lt;br /&gt; opts.merge!(:volume=&amp;gt;6,:ringtone=&amp;gt;:smooth_jazz)&lt;br /&gt;elsif caller.is_my_boss?&lt;br /&gt; opts.merge(:volume=&amp;gt;11,:ringtone=&amp;gt;:totally_obnoxious)&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;phone.ring!(opts)&lt;br /&gt;&lt;br /&gt;I don&amp;#39;t know how much better that is, really, since it requires introducing another local variable, but if you prefer only calling ring in one place rather than inside each conditional branch and the each clause at the end, it&amp;#39;s viable.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/4040698101945215484'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/4040698101945215484'/><link rel='alternate' type='text/html' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html?showComment=1288893955289#c4040698101945215484' title=''/><author><name>Ethan Vizitei</name><uri>http://www.blogger.com/profile/16886242271824345907</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='24' src='http://bp3.blogger.com/_vTrR73WnSs8/R41ZdF_kUeI/AAAAAAAAAqU/7ZbY4unHkXs/S220/me_with_glasses.jpg'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html' ref='tag:blogger.com,1999:blog-294680397865315179.post-1725024336631640560' source='http://www.blogger.com/feeds/294680397865315179/posts/default/1725024336631640560' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1211555502'/></entry><entry><id>tag:blogger.com,1999:blog-294680397865315179.post-5835908879043317047</id><published>2010-11-04T11:41:37.989-05:00</published><updated>2010-11-04T11:41:37.989-05:00</updated><title type='text'>In the first paragraph you say: &amp;quot;the conditio...</title><content type='html'>In the first paragraph you say: &amp;quot;the conditional could be constructed to just build the hash and only call the method in one place&amp;quot;. Can you please show an example?</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/5835908879043317047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/5835908879043317047'/><link rel='alternate' type='text/html' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html?showComment=1288888897989#c5835908879043317047' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html' ref='tag:blogger.com,1999:blog-294680397865315179.post-1725024336631640560' source='http://www.blogger.com/feeds/294680397865315179/posts/default/1725024336631640560' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-829769520'/></entry><entry><id>tag:blogger.com,1999:blog-294680397865315179.post-8141767458247320566</id><published>2010-11-04T11:15:17.490-05:00</published><updated>2010-11-04T11:15:17.490-05:00</updated><title type='text'>I prefer a pattern like this, so default values ar...</title><content type='html'>I prefer a pattern like this, so default values are reusable and not mixed throughout the code.&lt;br /&gt;&lt;br /&gt;class MyToolkit&lt;br /&gt; def defaults&lt;br /&gt;  @options ||= {&lt;br /&gt;   :opt     =&amp;gt; &amp;quot;value&amp;quot;,&lt;br /&gt;   :integer =&amp;gt; 33,&lt;br /&gt;   :type    =&amp;gt; &amp;quot;awesome&amp;quot;&lt;br /&gt;  }&lt;br /&gt; end&lt;br /&gt;&lt;br /&gt; def method(opts={})&lt;br /&gt;  # one time only option overrides&lt;br /&gt;  opts = defaults.merge(opts)&lt;br /&gt;  # OR... you can make the settings persist between method calls&lt;br /&gt;  defaults.merge!(opts)&lt;br /&gt;&lt;br /&gt;  # ... now do something useful&lt;br /&gt; end&lt;br /&gt;end</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/8141767458247320566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/294680397865315179/1725024336631640560/comments/default/8141767458247320566'/><link rel='alternate' type='text/html' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html?showComment=1288887317490#c8141767458247320566' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img1.blogblog.com/img/blank.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.ethanvizitei.com/2010/11/options-hash-classic-ruby-pattern.html' ref='tag:blogger.com,1999:blog-294680397865315179.post-1725024336631640560' source='http://www.blogger.com/feeds/294680397865315179/posts/default/1725024336631640560' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-1817351901'/></entry></feed>
