<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">
<channel>
<title>My Secret Life as a Spaghetti Coder</title>
<link>http://www.codeodor.com/</link>
<description>Posts about Ruby, Java, Coldfusion, OOAD, TDD, DSLs, and more (some not TLAs!)... </description>
<lastBuildDate>Thu, 01 Mar 2012 06:10:48 -0500</lastBuildDate>
<language>en-us</language>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/codeodor" /><feedburner:info uri="codeodor" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>codeodor</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
<title>How to avoid becoming a formerly-employed Rails developer standing in line at the OOP Kitchen</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/8blo7CFvpwI/3517</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2012/2/27/How-to-avoid-becoming-a-formerly-employed-Rails-developer-standing-in-line-at-the-OOP-Kitchen/3517</guid>
<pubDate>Thu, 01 Mar 2012 06:10:48 -0500</pubDate>
<description>Here's a 35 minute recording of the presentation which I gave to &lt;a href="http://www.houstonrb.com/"&gt;houstonrb&lt;/a&gt; on February 21, 2012. It is a practice run I did before the live presentation, so you won't get the discussion, but hopefully you'll find it useful anyway.
&lt;br/&gt;&lt;br/&gt;
&lt;iframe src="http://player.vimeo.com/video/37374175?title=0&amp;amp;byline=0&amp;amp;portrait=0" width="400" height="300" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen&gt;&lt;/iframe&gt;&lt;p&gt;&lt;a href="http://vimeo.com/37374175"&gt;How to avoid becoming a formerly-employed Rails developer standing in line at the OOP Kitchen&lt;/a&gt; from &lt;a href="http://vimeo.com/user10573188"&gt;Sammy Larbi&lt;/a&gt; on &lt;a href="http://vimeo.com"&gt;Vimeo&lt;/a&gt;.&lt;/p&gt;
&lt;br/&gt;&lt;br/&gt;
You can find the slides here: &lt;a href="http://bit.ly/oop-rails-slides"&gt;Slides for the Rails OOP presentation&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;
There is also reference to a project whose purpose is to eventually be a full-scale demonstration of the techniques: &lt;a href="http://bit.ly/oop-rails"&gt;Project for the Rails OOP presentation&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;
Let me know what you think in the comments below.
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;Updated&lt;/b&gt; to use HTML5 player at Vimeo.
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2012/2/27/How-to-avoid-becoming-a-formerly-employed-Rails-developer-standing-in-line-at-the-OOP-Kitchen/3517#leave_a_comment" title="Go to the page and comments for How to avoid becoming a formerly-employed Rails developer standing in line at the OOP Kitchen"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/8blo7CFvpwI" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Ruby]]></category>

<category><![CDATA[OOAD]]></category>

<category><![CDATA[Rails]]></category>

<category><![CDATA[Programming]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2012/2/27/How-to-avoid-becoming-a-formerly-employed-Rails-developer-standing-in-line-at-the-OOP-Kitchen/3517</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Better OO Design in Two Questions</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/j6w6AgDV0RY/3508</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2012/2/22/Better-OO-Design-in-Two-Questions/3508</guid>
<pubDate>Wed, 22 Feb 2012 08:24:54 -0500</pubDate>
<description>Someone rip this idea apart:
&lt;br/&gt;&lt;br/&gt;
When you write an &lt;code&gt;if&lt;/code&gt; statement in one class that's using data from an object of a different class to make a decision, ask yourself:
&lt;ol&gt;
&lt;li&gt;Would this code be more appropriate in the other object?&lt;/li&gt;
&lt;li&gt;Would it be better to introduce a new object, whose purpose it is to do this?&lt;/li&gt;
&lt;/ol&gt;
Thoughts appreciated.
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2012/2/22/Better-OO-Design-in-Two-Questions/3508#leave_a_comment" title="Go to the page and comments for Better OO Design in Two Questions"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/j6w6AgDV0RY" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Programming]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2012/2/22/Better-OO-Design-in-Two-Questions/3508</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Future Companies</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/bUvJixYF3_I/3499</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2012/2/8/Future-Companies/3499</guid>
<pubDate>Wed, 08 Feb 2012 06:51:43 -0500</pubDate>
<description>&lt;a href="https://twitter.com/#!/mbleigh/status/167005606073470977"&gt;&lt;img src="http://www.codeodor.com/images/future_companies_tweet.png" alt="Michael Bleigh's tweet saying 'In the future the only large companies will be those that help facilitate the sale and purchase of goods from small vendors to individuals.'"/&gt;&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;
My take at this concept was too long for twitter, and I was too lazy to pare it down:
&lt;br/&gt;&lt;br/&gt;
In the future, the only companies that sell physical goods* will be the ones that figure out how to mine atoms from raw materials which can be used as "ink" in 3d printers which people use to print their own products from (probably pirated) plans they found on the internet.
&lt;br/&gt;&lt;br/&gt;
* This excludes non-mass-produced art
&lt;br/&gt;&lt;br/&gt;
Thoughts?
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2012/2/8/Future-Companies/3499#leave_a_comment" title="Go to the page and comments for Future Companies"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/bUvJixYF3_I" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Future Tech]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2012/2/8/Future-Companies/3499</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Rethinking Routing in Rails</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/voCXdPMgmrg/3498</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2012/2/1/Rethinking-Routing-in-Rails/3498</guid>
<pubDate>Wed, 01 Feb 2012 05:44:32 -0500</pubDate>
<description>You know when you see code like this: 
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock"&gt;
  &lt;span style="color:#9966CC; font-weight:bold;"&gt;class&lt;/span&gt; CompulsionsController &amp;lt; ApplicationController&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &lt;span style="color:#008000; font-style:italic;"&gt;# ... standard actions above here&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; &lt;span style="color:#5A0A0A; font-weight:bold;"&gt;update&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;if&lt;/span&gt; params&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color:#ff3333; font-weight:bold;"&gt;:obsessions&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#93;&lt;/span&gt;.&lt;span style="color:#9966CC; font-weight:bold;"&gt;include&lt;/span&gt;?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;ObsessionsTypes&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color:#ff3333; font-weight:bold;"&gt;:murdering_small_animals&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; handle_sociopathic_obsessions &lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#5A0A0A; font-weight:bold;"&gt;redirect_to&lt;/span&gt; socio_path &lt;span style="color:#9966CC; font-weight:bold;"&gt;and&lt;/span&gt; &lt;span style="color:#0000FF; font-weight:bold;"&gt;return&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;elsif&lt;/span&gt; params&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color:#ff3333; font-weight:bold;"&gt;:obsessions&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#93;&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; handle_normal_obsessions&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#5A0A0A; font-weight:bold;"&gt;redirect_to&lt;/span&gt; standard_obsessions_path &lt;span style="color:#9966CC; font-weight:bold;"&gt;and&lt;/span&gt; &lt;span style="color:#0000FF; font-weight:bold;"&gt;return&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#008000; font-style:italic;"&gt;# normal update for compulsions &lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#0066ff; font-weight:bold;"&gt;@compulsion&lt;/span&gt; = Compulsions.&lt;span style="color:#9900CC;"&gt;find&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;params&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color:#ff3333; font-weight:bold;"&gt;:id&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;if&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;@compulsion.&lt;span style="color:#9900CC;"&gt;update_attributes&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;params&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#91;&lt;/span&gt;&lt;span style="color:#ff3333; font-weight:bold;"&gt;:compulsion&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#93;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color:#008000; font-style:italic;"&gt;# ... remainder of the standard actions below here &lt;/span&gt;&lt;br /&gt;
  &amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;/div&gt;

&lt;br/&gt;
and the phrase "WTF were they thinking?" runs through your mind?
&lt;more&gt;
&lt;br/&gt;&lt;br/&gt;
I have a theory about that little "pass a flag in the url to skip over the real action and perform a different one"
trick I see so often (and have been guilty of using myself).
&lt;br/&gt;&lt;br/&gt;
It's because you've got this omniscient file that knows everything about where to route requests 
that's not part of your editing routine, so finding and opening it breaks your train of thought. 
&lt;br/&gt;&lt;br/&gt;
It's a pain to open routes.rb when you suddenly realize you need a new route. 
&lt;br/&gt;&lt;br/&gt;
That got me thinking: 
&lt;b&gt;Should controllers route themselves?&lt;/b&gt; Would it make more sense for a controller to tell the router 
how each of it's actions should be reached?
&lt;br/&gt;&lt;br/&gt;
In the &lt;a href="http://www.amazon.com/gp/product/0735619670/ref=as_li_ss_tl?ie=UTF8&amp;tag=myseclifasasp-20&amp;linkCode=as2&amp;camp=1789&amp;creative=390957&amp;creativeASIN=0735619670"&gt;second edition of &lt;i&gt;Code Complete&lt;/i&gt;&lt;/a&gt; (that's an affiliate link), Steve McConnell writes about using 
the Principle of Proximity (page 352) as a way to think about organizing code. 
&lt;blockquote&gt;
  Keep related actions together.
&lt;/blockquote&gt;
From that point of view, it 
certainly would be easier to follow along when you're questioning "how do I get to this action?" 

Further, I think it would help solve the "pass a flag to an action to perform a different one" problem I illustrated in the code snippet above.
&lt;br/&gt;&lt;br/&gt;
It was on my mind over the weekend, so I put together this little 
&lt;a href="https://github.com/codeodor/route"&gt;experiment to see what controllers routing themselves in Rails&lt;/a&gt; would look like.
In that repository is a one-controller Rails project which specifies routes to itself using a gem you'll find in 
&lt;code&gt;vendor/gems/route&lt;/code&gt;. 
&lt;br/&gt;&lt;br/&gt;
One major drawback to doing routing in this style has to do with nested routes: should a controller that's 
part of a nested route know who it's parents are? Should a higher-in-the-nest controller know about its child 
routes? And if you choose one or the other, how would you specify it? What if there are conflicting routes -- who wins out?
&lt;br/&gt;&lt;br/&gt;
It leads to a lot of questions for which I have no immediate answers.
&lt;br/&gt;&lt;br/&gt;
Anyway, what do you think? Would this help solve the problem of recycled routes? Is that even a problem?
&lt;br/&gt;&lt;br/&gt;
&lt;strong&gt;What are the drawbacks of such an approach? Do you see any merits?&lt;/b&gt;&lt;/strong&gt;
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2012/2/1/Rethinking-Routing-in-Rails/3498#leave_a_comment" title="Go to the page and comments for Rethinking Routing in Rails"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/voCXdPMgmrg" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Rails]]></category>

<category><![CDATA[Programming]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2012/2/1/Rethinking-Routing-in-Rails/3498</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>APIs have the signup process backwards</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/8RSp85gEuIw/3489</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2012/1/27/APIs-have-the-signup-process-backwards/3489</guid>
<pubDate>Fri, 27 Jan 2012 06:01:16 -0500</pubDate>
<description>Most online developer API services that I've used are set up as if the customer is also the software developer. 
&lt;br/&gt;&lt;br/&gt;
That should change.
&lt;br/&gt;&lt;br/&gt;
As the software developer, I don't want to be the owner of my customer's accounts, and I don't 
want to worry about trying to figure out how to transfer ownership (if your service allows it, that is). 
Because of that, theres a lot of waste that goes on: wastes of my time, 
which wastes my customer's or my company's money.
&lt;br/&gt;&lt;br/&gt;
I'm saying "customer" here, but you might substitute that with "the person who really needs / cares about the account," 
because that person, in my estimation, is rarely the software developer. Unless I'm developing an app for myself, 
I only care about that API because someone else needs me to. And even when I'm developing for myself, I hope it gets to 
a point where I need to hire someone to care about it on my behalf, so I can focus on more important things.
&lt;br/&gt;&lt;br/&gt;
The typical signup process for me goes like this: &lt;more&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;img src="http://www.codeodor.com/images/TypicalAPISignup.png" alt="Typical API signup process, described in list below."&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;ol&gt;
&lt;li&gt;Me: If I already have an account, sign out.&lt;/li&gt;
&lt;li&gt;Me: Sign up for the service. Find what I need to integrate with the API. Note the steps I perform.   &lt;/li&gt;
&lt;li&gt;Customer: Signs up for the service, with me providing the steps they'll need to take.&lt;/li&gt;
&lt;li&gt;Me: Ask my customer to give me the info I need, or grant me access if that option is available.&lt;/li&gt;
&lt;li&gt;Customer: "I can't figure it out, here's my login info, find it please."   &lt;/li&gt;
&lt;li&gt;Me: I find the info, and tell the customer to reset their password. I doubt they ever do. &lt;/li&gt;
&lt;/ol&gt;
&lt;br/&gt;
&lt;em&gt;You're offering the service, yet there's no "you" in that process.&lt;/em&gt;
&lt;br/&gt;&lt;br/&gt;
Here's the process I'd like to see:
&lt;br/&gt;&lt;br/&gt;
&lt;img width="475" src="http://www.codeodor.com/images/BetterAPISignup.png" alt="A better API signup process, described in list below."&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;ol&gt;
&lt;li&gt;You: Tell me I can easily transfer the account (or project or access keys) before I bother to sign up&lt;/li&gt;
&lt;li&gt;Me: Sign up for an account for myself. &lt;/li&gt;
&lt;li&gt;Me: Get everything working. &lt;/li&gt;
&lt;li&gt;Me and You: If I know my customer already has an account, provide a place for me to enter my customer's email address. If you offer more than one thing I'll need access to, let me indicate what I need for this project.&lt;/li&gt;
&lt;ul&gt;&lt;li&gt;You: Send detailed instructions of to grant access to my needs.&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;You: If my customer does not have an account, you send them detailed instructions for how to sign up and what they'll need to know to get value from your service.
&lt;ul&gt;&lt;li&gt;Customer: signs up for their account, indicating they are actually working with me. &lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;You: Hook up our accounts, with me transferring ownership of that "project" to my customer.&lt;/li&gt;
&lt;/ol&gt;
&lt;br/&gt;
&lt;strong&gt;There's a lot less of me and my customer in that process, and a lot more of you&lt;/strong&gt;. 
It's certainly more complex, but it's simpler for the people who matter: your users. 

&lt;br/&gt;&lt;br/&gt;
Remember, the software developer is often the one who makes recommendations as to which products to use. Make 
it easier for me, and I'll be more likely to choose your service over a competing one.
&lt;br/&gt;&lt;br/&gt;
&lt;span style="font-size: 9pt;"&gt;
post scriptum side note: I used &lt;a href="https://www.lucidchart.com"&gt;Lucid Chart&lt;/a&gt; to do the flow charts. I really
like it, but given how rarely I've wanted to diagram online, I don't see myself becoming a paid 
subscriber. What do you use?
&lt;/span&gt;
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2012/1/27/APIs-have-the-signup-process-backwards/3489#leave_a_comment" title="Go to the page and comments for APIs have the signup process backwards"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/8RSp85gEuIw" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Tools]]></category>

<category><![CDATA[Web Development]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2012/1/27/APIs-have-the-signup-process-backwards/3489</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Three passive-aggressive ways to feel like you're getting back at typecasers</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/S0jxgZzDUmk/3475</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2011/12/21/Three-passive-aggressive-ways-to-feel-like-youre-getting-back-at-typecasers/3475</guid>
<pubDate>Wed, 21 Dec 2011 08:49:56 -0500</pubDate>
<description>&lt;a href="https://twitter.com/codeodor/status/149284840871702528"&gt;
  &lt;img src="http://www.codeodor.com/images/typecase_tweet.png" alt="My vocabulary is failing me right now. What do you call it when a piece of code checks the type of an object before doing something to it?"/&gt;
&lt;/a&gt;
&lt;br/&gt;&lt;br/&gt;

&lt;a href="http://c2.com/cgi/wiki?TypeCase"&gt;Type Casing&lt;/a&gt; is the act of using case statements 
in a program to determine what to do with an object based on what type of object it is. It's an OO fail, often 
hoping to implement &lt;a href="http://c2.com/cgi/wiki?MultipleDispatch"&gt;Multiple Dispatch&lt;/a&gt;. (See also 
&lt;a href="http://c2.com/cgi/wiki?CaseStatementsConsideredHarmful"&gt;Case Statements Considered Harmful&lt;/a&gt;)
&lt;br/&gt;&lt;br/&gt;
Here are three passive-aggressive ways to feel like you're getting back at typecasers. 
&lt;br/&gt;&lt;br/&gt;&lt;more&gt;
The first tactic turns your object into an &lt;em&gt;everything&lt;/em&gt;, so it's whatever the typecaser was looking for. I've called it 
&lt;code&gt;OmniObject&lt;/code&gt;.
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"&gt;&lt;span style="color:#9966CC; font-weight:bold;"&gt;module&lt;/span&gt; OmniObject&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; is_a?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color:#0000FF; font-weight:bold;"&gt;true&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; kind_of?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color:#0000FF; font-weight:bold;"&gt;true&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; &lt;span style="color:#0000FF; font-weight:bold;"&gt;nil&lt;/span&gt;?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color:#0000FF; font-weight:bold;"&gt;true&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
foo = &lt;span style="color:#996600;"&gt;&amp;quot;hello, world!&amp;quot;&lt;/span&gt;&lt;br /&gt;
foo.&lt;span style="color:#9900CC;"&gt;extend&lt;/span&gt; OmniObject&lt;br /&gt;
&lt;span style="color:#CC0066; font-weight:bold;"&gt;puts&lt;/span&gt; &lt;span style="color:#996600;"&gt;&amp;quot;Is foo a Fixnum? #{foo.is_a?(Fixnum) ? 'yes' : 'no'}&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color:#CC0066; font-weight:bold;"&gt;puts&lt;/span&gt; &lt;span style="color:#996600;"&gt;&amp;quot;Is foo a Kernel? #{foo.is_a?(Kernel) ? 'yes' : 'no'}&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color:#CC0066; font-weight:bold;"&gt;puts&lt;/span&gt; &lt;span style="color:#996600;"&gt;&amp;quot;Is foo a NilClass? #{foo.kind_of?(NilClass) ? 'yes' : 'no'}&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color:#CC0066; font-weight:bold;"&gt;puts&lt;/span&gt; &lt;span style="color:#996600;"&gt;&amp;quot;foo.nil? =&amp;gt; #{foo.nil?}&amp;quot;&lt;/span&gt;&lt;/div&gt;
&lt;br/&gt;

The next one makes your object unable to decide what it is, turning it into a &lt;code&gt;FickleTeenager&lt;/code&gt;. If he has to check more than once, 
the typecaser is going to have a tough time with a kid who can't make up his mind.
&lt;br/&gt;&lt;br/&gt;

&lt;div class="codeBlock" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"&gt;&lt;span style="color:#9966CC; font-weight:bold;"&gt;module&lt;/span&gt; FickleTeenager&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; is_a?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sorta&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; kind_of?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sorta&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; &lt;span style="color:#0000FF; font-weight:bold;"&gt;nil&lt;/span&gt;?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; sorta&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; sorta&lt;br /&gt;
&amp;nbsp; &amp;nbsp; truish&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; truish&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color:#CC0066; font-weight:bold;"&gt;rand&lt;/span&gt; &lt;span style="color:#006600; font-weight:bold;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#006666;"&gt;0.5&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
foo = &lt;span style="color:#996600;"&gt;&amp;quot;hello, world!&amp;quot;&lt;/span&gt;&lt;br /&gt;
foo.&lt;span style="color:#9900CC;"&gt;extend&lt;/span&gt; FickleTeenager&lt;br /&gt;
&lt;span style="color:#006666;"&gt;3&lt;/span&gt;.&lt;span style="color:#9900CC;"&gt;times&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#123;&lt;/span&gt; &lt;span style="color:#CC0066; font-weight:bold;"&gt;puts&lt;/span&gt; &lt;span style="color:#996600;"&gt;&amp;quot;Is foo a String? #{foo.kind_of?(String) ? 'yes' : 'no'}&amp;quot;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#125;&lt;/span&gt;&lt;/div&gt;
&lt;br/&gt;
Finally, we have the &lt;code&gt;AntisocialPrivacyAdvocate&lt;/code&gt;. When the typecaser asks him what he is, he tells them like it is: It's none of your damn business!
&lt;br/&gt;&lt;br/&gt;
&lt;div class="codeBlock" style="font-family:monospace;color: #006; border: 1px solid #d0d0d0; background-color: #f0f0f0;"&gt;&lt;span style="color:#9966CC; font-weight:bold;"&gt;class&lt;/span&gt; WhatBusinessOfItIsYoursError &lt;span style="color:#006600; font-weight:bold;"&gt;&amp;lt;&lt;/span&gt; &lt;span style="color:#CC00FF; font-weight:bold;"&gt;StandardError&lt;/span&gt;; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color:#9966CC; font-weight:bold;"&gt;module&lt;/span&gt; AntisocialPrivacyAdvocate&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; is_a?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span style="color:#CC0066; font-weight:bold;"&gt;raise&lt;/span&gt; &amp;nbsp;WhatBusinessOfItIsYoursError&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; kind_of?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;*&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; is_a?&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;def&lt;/span&gt; &lt;span style="color:#0000FF; font-weight:bold;"&gt;nil&lt;/span&gt;?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; is_a?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#CC00FF; font-weight:bold;"&gt;NilClass&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;span style="color:#9966CC; font-weight:bold;"&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
foo = &lt;span style="color:#996600;"&gt;&amp;quot;hello, world!&amp;quot;&lt;/span&gt;&lt;br /&gt;
foo.&lt;span style="color:#9900CC;"&gt;extend&lt;/span&gt; AntisocialPrivacyAdvocate&lt;br /&gt;
result = foo.&lt;span style="color:#9900CC;"&gt;kind_of&lt;/span&gt;?&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#40;&lt;/span&gt;&lt;span style="color:#CC0066; font-weight:bold;"&gt;String&lt;/span&gt;&lt;span style="color:#006600; font-weight:bold;"&gt;&amp;#41;&lt;/span&gt; &lt;span style="color:#9966CC; font-weight:bold;"&gt;rescue&lt;/span&gt; &lt;span style="color:#996600;"&gt;&amp;quot;#{$!} OMG, How Rude!&amp;quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color:#CC0066; font-weight:bold;"&gt;puts&lt;/span&gt; result&lt;/div&gt;

	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2011/12/21/Three-passive-aggressive-ways-to-feel-like-youre-getting-back-at-typecasers/3475#leave_a_comment" title="Go to the page and comments for Three passive-aggressive ways to feel like you're getting back at typecasers"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/S0jxgZzDUmk" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Ruby]]></category>

<category><![CDATA[Programming]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2011/12/21/Three-passive-aggressive-ways-to-feel-like-youre-getting-back-at-typecasers/3475</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>How do you get two secure sites to cooperate and operate seamlessly for the end user?</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/KHSn2Lm1IRo/3465</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2011/12/9/How-do-you-get-two-secure-sites-to-cooperate-and-operate-seamlessly-for-the-end-user/3465</guid>
<pubDate>Fri, 09 Dec 2011 06:13:19 -0500</pubDate>
<description>Suppose you have some awesome analytics tool that provides great value to a bank's customer, but 
they need to interact with it through the bank's website, and you need to host the tool.
&lt;br/&gt;&lt;br/&gt;
You already have the data you need for the analytics to work, and the only missing piece you're left
to consider is "how do I know to whom to show which data?"
&lt;br/&gt;&lt;br/&gt;
The data is private, so you need to ensure you're not showing it to someone who's not authorized to see it.
&lt;br/&gt;&lt;br/&gt;
&lt;more&gt;
&lt;img src="http://www.codeodor.com/images/locked.jpg" alt="An insecure lock" width="475"/&gt;&lt;br/&gt;
&lt;span style="font-size: 8pt;"&gt;
  Photo by &lt;a href="http://www.flickr.com/photos/rimuhosting/5092109793/"&gt;pbkwee&lt;/a&gt;
&lt;/span&gt;
&lt;br/&gt;&lt;br/&gt;
Some more constraints: 
&lt;ul&gt;
&lt;li&gt;
  You don't want to generate thousands of usernames and passwords that would create more burden for the 
  users (and force them to log in twice)
&lt;/li&gt;
&lt;li&gt;
  You can't hook into the bank's user system. (nor would you want to, since they'd still have to log in twice)
&lt;/li&gt;
&lt;li&gt;
  You want this to be reasonably simple for the bank to implement whatever they need to do to make it
  work on their end.
&lt;/li&gt;
&lt;/ul&gt;

To show it on their site, you decide to create a template-less app that they'll embed in an iframe. 
&lt;br/&gt;&lt;br/&gt;
So what authorization mechanism do you use to know who should see which data?
&lt;br/&gt;&lt;br/&gt;
One idea I had was to simply restrict which IP addresses (to those of the bank) the app would respond to. 
Then they could just request a page via HTTP and serve up our response. But in order to get that to work,
there's too much that needs to be done: we have to coordinate all URLs with whatever the bank decides
they should be, and they have to figure out whether to GET, POST, PUT, etc. back to us.
&lt;br/&gt;&lt;br/&gt;
The next idea was to have a single page that is restricted by IP address (to those of the bank), where 
they will make an HTTP request to receive a token that expires after some length of time (or at the bank's 
request, if they hit another URL to invalidate the token). The bank includes the token in the iframe src 
URL which lets you know whose data to show. 
&lt;br/&gt;&lt;br/&gt;
But I'm really interested in hearing your thoughts. &lt;b&gt;How would you do it?&lt;/b&gt; Is there a
standard way of doing this already?
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2011/12/9/How-do-you-get-two-secure-sites-to-cooperate-and-operate-seamlessly-for-the-end-user/3465#leave_a_comment" title="Go to the page and comments for How do you get two secure sites to cooperate and operate seamlessly for the end user?"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/KHSn2Lm1IRo" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Web Development]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2011/12/9/How-do-you-get-two-secure-sites-to-cooperate-and-operate-seamlessly-for-the-end-user/3465</feedburner:origLink></item>





	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	

	


	
	








	
	
	


<item>
<title>Ruby random numbers</title>
<link>http://feedproxy.google.com/~r/codeodor/~3/FBJ5z-RloMg/1042</link>
<guid isPermaLink="false">http://www.codeodor.com/index.cfm/2007/3/25/Ruby-random-numbers/1042</guid>
<pubDate>Wed, 15 Feb 2012 05:58:21 -0500</pubDate>
<description>&lt;b&gt;Update:&lt;/b&gt; Ruby 1.9.3 adds the ability to use ranges as arguments to &lt;code&gt;rand&lt;/code&gt;, which produces more obvious code. So if you're using it, instead of using "magic offsets" like I did in the original post (as Joni Orponen mentions in the comments below), it would be better to use &lt;code&gt;rand(1..6)&lt;/code&gt; to simulate a die roll.
&lt;br/&gt;&lt;br/&gt;
So to summarize: if you need a percentage between 0 and 1, just call &lt;code&gt;rand&lt;/code&gt;. If you need an integer between 0 and x (not including x), you can still call &lt;code&gt;rand(x)&lt;/code&gt;. Finally, if you need a number in a specific range, just call &lt;code&gt;rand(x..y)&lt;/code&gt; where x is the lower bound of the range, and y is the higher end. 
&lt;br/&gt;&lt;br/&gt;
(And recall that if you want a non-inclusive range, you can use 3 periods, like &lt;code&gt;rand(1...100)&lt;/code&gt; to get numbers from 1 to 99. Although if you're typing the number out, it's certainly better to use &lt;code&gt;1..99&lt;/code&gt;, if you had used a variable in the higher part of the range, the 3rd period is preferable to &lt;code&gt;1..(x-1)&lt;/code&gt;, in my opinion.) 
&lt;br/&gt;&lt;br/&gt;
The original post follows:
&lt;br/&gt;&lt;br/&gt;
Another quick note today... I surprisingly have yet to need a random number in Ruby up to this point (or forgot if I did), so I went through a little hassle trying to find out how.  Turns out, you can simply use &lt;code&gt;rand(int)&lt;/code&gt;. So, if you needed a random integer to simulate a roll of a six-sided die, you'd use: &lt;code&gt;1 + rand(6)&lt;/code&gt;.  A roll in craps could be simulated with &lt;code&gt;2 + rand(6) + rand(6)&lt;/code&gt;.  
&lt;br/&gt;&lt;br/&gt;
Finally, if you just need a random float, just call &lt;code&gt;rand&lt;/code&gt; with no arguments.  After that, you can modify the range as you normally would in anything else (i.e., using addition and multiplication).
&lt;br/&gt;&lt;br/&gt;
I guess I used some crappy search terms, because I couldn't find this via google, and I didn't see it skimming the usual suspects in the Ruby docs.
	&lt;div align="right"&gt;
		&lt;a href="http://www.codeodor.com/index.cfm/2007/3/25/Ruby-random-numbers/1042#leave_a_comment" title="Go to the page and comments for Ruby random numbers"&gt;Comments?&lt;/a&gt;
	&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeodor/~4/FBJ5z-RloMg" height="1" width="1"/&gt;</description>
<dc:creator>Sammy Larbi</dc:creator>

<category><![CDATA[Ruby]]></category>

<feedburner:origLink>http://www.codeodor.com/index.cfm/2007/3/25/Ruby-random-numbers/1042</feedburner:origLink></item>

</channel>
</rss>

