<?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 version="2.0">
  <channel>
    <title>patnakajima.com: Articles</title>
    <description>Aggregating and aggravating since 1986.</description>
    <link>http://blog.patnakajima.com/posts.rss</link>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/pat-nakajima-articles" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="pat-nakajima-articles" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
      <title>On “doing cool shit...”</title>
      <description>&lt;p&gt;Any argument against re-inventing the wheel or that can be summed up by &amp;#8220;don&amp;#8217;t try to fix it if it isn&amp;#8217;t broken&amp;#8221; is usually made by someone who hasn&amp;#8217;t done anything worthwhile.&lt;/p&gt;
&lt;p&gt;Argue with me.&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/on-doing-cool-shit.rss</guid>
      <pubDate>Wed, 19 Nov 2008 08:13:09 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/on-doing-cool-shit.rss</link>
    </item>
    <item>
      <title>This is a blog, damnit.</title>
      <description>&lt;p&gt;It&amp;#8217;s about time I post some posts. I&amp;#8217;m figuring the stuff not worth spamming my Twitter followers is going to end up here. Unsubscribe at will. I know I will.&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/this-is-a-blog-damnit.rss</guid>
      <pubDate>Wed, 19 Nov 2008 08:00:04 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/this-is-a-blog-damnit.rss</link>
    </item>
    <item>
      <title>East Village on Election Night</title>
      <description>&lt;p&gt;&lt;object type="application/x-shockwave-flash" width="500" height="375" data="http://www.flickr.com/apps/video/stewart.swf?v=61761" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"&gt; &lt;param name="flashvars" value="intl_lang=en-us&amp;amp;photo_secret=843cd41e3e&amp;amp;photo_id=3005157740"&gt;&lt;/param&gt; &lt;param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=61761"&gt;&lt;/param&gt; &lt;param name="bgcolor" value="#000000"&gt;&lt;/param&gt; &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=61761" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;amp;photo_secret=843cd41e3e&amp;amp;photo_id=3005157740" height="375" width="500"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/east-village-on-election-night.rss</guid>
      <pubDate>Thu, 06 Nov 2008 00:49:59 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/east-village-on-election-night.rss</link>
    </item>
    <item>
      <title>Times Square on Election Night</title>
      <description>&lt;p&gt;&lt;object type="application/x-shockwave-flash" width="500" height="375" data="http://www.flickr.com/apps/video/stewart.swf?v=61761" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"&gt; &lt;param name="flashvars" value="intl_lang=en-us&amp;amp;photo_secret=5c7921fe03&amp;amp;photo_id=3004300815"&gt;&lt;/param&gt; &lt;param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=61761"&gt;&lt;/param&gt; &lt;param name="bgcolor" value="#000000"&gt;&lt;/param&gt; &lt;param name="allowFullScreen" value="true"&gt;&lt;/param&gt;&lt;embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=61761" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;amp;photo_secret=5c7921fe03&amp;amp;photo_id=3004300815" height="375" width="500"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/times-square-on-election-night.rss</guid>
      <pubDate>Thu, 06 Nov 2008 00:49:25 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/times-square-on-election-night.rss</link>
    </item>
    <item>
      <title>Conditionals in method names considered annoying</title>
      <description>&lt;p&gt;I&amp;#8217;ve been noticing a few projects recently where there are&lt;br /&gt;
method names that contain conditional descriptions, such as&lt;br /&gt;
&lt;code&gt;foo_if_bar&lt;/code&gt; or &lt;code&gt;rant_if_loaded&lt;/code&gt;. Here&amp;#8217;s where I weigh in:&lt;br /&gt;
Don&amp;#8217;t do it. The right way to name those methods is simply&lt;br /&gt;
&lt;code&gt;foo&lt;/code&gt; and &lt;code&gt;rant&lt;/code&gt;. If &lt;code&gt;foo&lt;/code&gt; really only ought to be called&lt;br /&gt;
when &lt;code&gt;bar&lt;/code&gt; is true, then a simple guard clause ought to work:&lt;/p&gt;
def foo
return unless bar
# foo logic goes here
end
&lt;p&gt;This works most of the time, when no one cares whether or&lt;br /&gt;
not &lt;code&gt;foo&lt;/code&gt; relies upon &lt;code&gt;bar&lt;/code&gt;. If it&amp;#8217;s important that readers&lt;br /&gt;
of your code see that &lt;code&gt;foo&lt;/code&gt; only happens when &lt;code&gt;bar&lt;/code&gt; is true,&lt;br /&gt;
then you can just specify the conditional wherever you invoke&lt;br /&gt;
the method:&lt;/p&gt;
def fizz
foo if bar # make it clear that we only foo if bar
end
&lt;h3&gt;Why?&lt;/h3&gt;
&lt;p&gt;You should ask &lt;a href="http://evang.eli.st/blog"&gt;the other Pat&lt;/a&gt; if you&lt;br /&gt;
want the good answer, but I&amp;#8217;ll try to put it as well as possible.&lt;/p&gt;
&lt;p&gt;First of all, requirements change. So at some point, &lt;code&gt;foo&lt;/code&gt; may&lt;br /&gt;
be callable without ever worrying about &lt;code&gt;bar&lt;/code&gt;. By leaving the&lt;br /&gt;
conditional crap out of the method name, you can remove the conditional&lt;br /&gt;
logic as needed, and aren&amp;#8217;t stuck using a method name that no&lt;br /&gt;
longer means what it says.&lt;/p&gt;
&lt;p&gt;If the conditional logic can be in-lined as a guard clause, then&lt;br /&gt;
a method name with conditional bits is leaking information about&lt;br /&gt;
implementation. If the conditional logic should be placed alongside&lt;br /&gt;
method calls, then putting the conditional description in the method&lt;br /&gt;
name is just redundant.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span class="caps"&gt;FYI&lt;/span&gt;: I intend to post some cool stuff soon, so this blog isn&amp;#8217;t&lt;br /&gt;
solely populated by stuff that bugs me.&lt;/em&gt;&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/conditionals-in-method-names-considered-annoying.rss</guid>
      <pubDate>Sat, 25 Oct 2008 09:45:31 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/conditionals-in-method-names-considered-annoying.rss</link>
    </item>
    <item>
      <title>Your underscores are showing</title>
      <description>&lt;p&gt;Listen: You&amp;#8217;re writing some Rails code, as you tend to do. All of &lt;br /&gt;
the sudden, you recognize the need for an association that goes both&lt;br /&gt;
ways. You could use a &lt;code&gt;has_many_and_belongs_to_many&lt;/code&gt; but that dude you&amp;#8217;ve&lt;br /&gt;
heard of said that you should be using &lt;code&gt;has_many :through&lt;/code&gt; instead. So&lt;br /&gt;
you say &amp;#8220;join tables? pfft! join models!&amp;#8221;&lt;/p&gt;
&lt;p&gt;So you need to create your join model. First, you need a name.&lt;/p&gt;
&lt;p&gt;Here&amp;#8217;s where many, if not most, go wrong. Let&amp;#8217;s say you&amp;#8217;ve got a &lt;code&gt;User&lt;/code&gt;&lt;br /&gt;
model and a &lt;code&gt;Compulsion&lt;/code&gt; model. A &lt;code&gt;User&lt;/code&gt; can have many &lt;code&gt;:compulsions&lt;/code&gt;, and&lt;br /&gt;
a &lt;code&gt;Compulsion&lt;/code&gt; can afflict many &lt;code&gt;:users&lt;/code&gt;.&lt;/p&gt;
&lt;h3&gt;For the love and/or respect of everthing remotely decent, do not name&lt;br /&gt;
that join model UserCompulsion.&lt;/h3&gt;
&lt;p&gt;It&amp;#8217;s a stupid name. And it&amp;#8217;s not even the worst. Not by a longshot. It&amp;#8217;s just&lt;br /&gt;
the worst I could think of while concocting this convoluted example of a&lt;br /&gt;
practice I regularly lament. Why is it stupid? Because it does nothing but says&lt;br /&gt;
&amp;#8220;hey, these two things are related, but I dare you to try figuring out how.&amp;#8221;&lt;/p&gt;
&lt;p&gt;Join &lt;em&gt;models&lt;/em&gt; should describe the relationship that they&amp;#8217;re &lt;em&gt;modeling&lt;/em&gt;. You don&amp;#8217;t&lt;br /&gt;
call your &lt;code&gt;User&lt;/code&gt; table &lt;code&gt;name_username_passwords&lt;/code&gt;, because that wouldn&amp;#8217;t divulge&lt;br /&gt;
any information about your problem domain. Only rubbish about your implementation.&lt;br /&gt;
That&amp;#8217;s lousy. In this spirit you should give your join models a name that counts.&lt;/p&gt;
&lt;p&gt;So what do you call your join model between a &lt;code&gt;User&lt;/code&gt; and a &lt;code&gt;Compulsion&lt;/code&gt;? Well,&lt;br /&gt;
an &lt;code&gt;Obsession&lt;/code&gt; may be appropriate. &amp;#8220;But wait!&amp;#8221; you say, that doesn&amp;#8217;t apply to your&lt;br /&gt;
particular problem domain. Then pick something that does. An underscore can&amp;#8217;t possibly&lt;br /&gt;
convey the problem solved by your creation of a join model.&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/your-underscores-are-showing.rss</guid>
      <pubDate>Fri, 24 Oct 2008 06:33:05 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/your-underscores-are-showing.rss</link>
    </item>
    <item>
      <title>My Cuil experience</title>
      <description>&lt;p&gt;With all the hubbub about &lt;a href="http://cuil.com"&gt;Cuil&lt;/a&gt; these days, I thought I&amp;#8217;d give it a whirl. And what better way to try out a new search engine than a self-search?&lt;/p&gt;
&lt;div style="float:right; border-bottom: 1px solid #e0e0e0; border-left: 1px solid #eee; border-right: 1px solid #eee; margin-top: 10px;"&gt;
&lt;p&gt;&lt;img src="http://s3.amazonaws.com/patnakajima/images/cuil-ok.png" alt="" /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;Cuil found most of the pertinent details about me, though there were a few unanswered questions. The biggest mystery, of course, was who on earth is the guy that they pictured next to the result for &lt;a href="http://patnakajima.com"&gt;patnakajima.com&lt;/a&gt;?&lt;/p&gt;
&lt;p&gt;The only other weird thing about Cuil is how much their results just look like Google ads, which I strive so hard to ignore when looking at regular Google search results.&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/my-cuil-experience.rss</guid>
      <pubDate>Wed, 30 Jul 2008 01:17:05 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/my-cuil-experience.rss</link>
    </item>
    <item>
      <title>Remember the :active styles</title>
      <description>&lt;p&gt;The hyperlinks of today look way better than they did five years ago. Designers and developers have become better and better at styling links to not only be usable, but beautiful as well. We know how to indicate the basic behavior of a link using only color (for example, red usually indicates a destructive action). And we know how to style links to give them a stronger affordance of click-ability.&lt;/p&gt;
&lt;p&gt;Most web applications make clever use of the &lt;code&gt;:hover&lt;/code&gt; pseudo-class, which allows us to tweak link backgrounds to add an even stronger affordance of click-ability, and draws the eye to the link, which focuses the user on task at hand. All of &lt;a href="http://37signals.com"&gt;37signals&amp;#8217;&lt;/a&gt; apps provide great examples of tasteful rollover link styles.&lt;/p&gt;
&lt;p&gt;&lt;strong class="highlight"&gt;When we begin to think about rollover styles, we&amp;#8217;re no longer thinking about how the app looks. We&amp;#8217;re thinking about how it feels.&lt;/strong&gt; Different styles for link rollovers make a page feel much more responsive. Everybody these days knows this, and takes advantage of it.&lt;/p&gt;
&lt;p&gt;Unfortunately, few people take advantage of the &lt;code&gt;:active&lt;/code&gt; pseudo-class, which allows you to style the link differently while it&amp;#8217;s being clicked. This is just as important, if not &lt;em&gt;more&lt;/em&gt; important than the rollover state. Changing a link&amp;#8217;s &lt;code&gt;:active&lt;/code&gt; style provides immediate visual feedback that the link is being clicked.&lt;/p&gt;
&lt;p&gt;Try clicking each of the following links. See which feels better.&lt;/p&gt;
&lt;div id="active_example"&gt;
  &lt;p&gt;&lt;a href="#" id="noActive" onclick="return false;"&gt;This link does not have an active state.&lt;/a&gt;&lt;/p&gt;
  &lt;p&gt;&lt;a href="#" id="yesActive" onclick="return false;"&gt;This link does have an active state.&lt;/a&gt;&lt;/p&gt;
&lt;style type="text/css" media="screen"&gt;
#noActive:hover, #yesActive:hover { background: #313131; text-decoration: none; }
#active_example a { padding: 0.2em; }
#noActive:active { background: #313131; }
#yesActive:active { background: #000; }
&lt;/style&gt;
&lt;/div&gt;
&lt;p&gt;The chances of a person successfully completing a task increase with the level of feedback that that he/she receives before, while, and after performing that task. (if you&amp;#8217;ve read &lt;a href="http://www.amazon.com/Design-Everyday-Things-Don-Norman/dp/0465067107"&gt;The Design of Everyday Things&lt;/a&gt;, you know what I&amp;#8217;m talking about). With links, the &amp;#8220;before&amp;#8221; feedback can be achieved using &lt;code&gt;:hover&lt;/code&gt; styles, and the &amp;#8220;after&amp;#8221; feedback is usually just the browser doing something, be it going to a different page or just updating something dynamically. &lt;strong class="highlight"&gt;The &amp;#8220;during&amp;#8221; feedback can be achieved by simply using a good &lt;code&gt;:active&lt;/code&gt; style.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Now, just as much thought must be given to a link&amp;#8217;s &lt;code&gt;:active&lt;/code&gt; style as to its &lt;code&gt;:hover&lt;/code&gt; style, if not more. Usually, a click is less than a second, so changing the style too much can be distracting, and actually do more harm than good. I&amp;#8217;ve found that the best &lt;code&gt;:active&lt;/code&gt; styles tend to just make the background a bit darker. I first saw this on &lt;a href="http://flickr.com"&gt;flickr&lt;/a&gt; (which was where I first noticed the &lt;code&gt;:active&lt;/code&gt; state in use and fell in love). You might also think about adding an underline during the click. Experiment and see what works best for you.&lt;/p&gt;
&lt;p&gt;One thing&amp;#8217;s for sure though. Once you feel the difference in your web apps between a good &lt;code&gt;:active&lt;/code&gt; style and a non-existent one, you&amp;#8217;ll wish every site made use of them.&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/remember-the-active-styles.rss</guid>
      <pubDate>Tue, 29 Jul 2008 02:45:40 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/remember-the-active-styles.rss</link>
    </item>
    <item>
      <title>“ASSISTANZA”</title>
      <description>&lt;p&gt;I love these.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Dear Friend,&lt;/p&gt;
&lt;p&gt;I am an official for a bank here in Milano. I require your assistance and partnership in transferring huge amount of funds in euros out of Italy. You will be required to:&lt;/p&gt;
&lt;p&gt;(1) Assist in the transfer of the said sum.&lt;/p&gt;
&lt;p&gt;(2) Advise on lucrative areas for subsequent investment.&lt;/p&gt;
&lt;p&gt;(3) Assist me in purchase of landed &amp;amp; viable properties.&lt;/p&gt;
&lt;p&gt;Should you be willing to assist us in the transaction, your share of the sum will be 30% of the €21,500,000.00, 65% for us and 5% for taxation and miscellaneous expenses. Please establish secured communication with me through my email address.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Toma Petrova&lt;/p&gt;
&lt;/blockquote&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/assistanza.rss</guid>
      <pubDate>Thu, 19 Jun 2008 13:52:01 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/assistanza.rss</link>
    </item>
    <item>
      <title>UI Glitch at Smashing Magazine</title>
      <description>&lt;p&gt;&lt;a href="http://smashingmagazine.com"&gt;Smashing Magazine&lt;/a&gt; is a great site. Full of beautiful site designs and helpful tidbits, it has only one major failing: its pagination.&lt;/p&gt;
&lt;p&gt;This is what the links at the bottom look like:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://s3.amazonaws.com/patnakajima/images/smashing_ui_bug.png" title="Confusing to me" alt="Confusing to me" /&gt;&lt;/p&gt;
&lt;p&gt;To get to the next page, you&amp;#8217;re expected to click the &amp;#8220;»&amp;#8221;. It&amp;#8217;s unlabeled, and a rather small target (&lt;a href="http://en.wikipedia.org/wiki/Fitts&amp;#39;_law"&gt;Fitts&amp;#8217; Law&lt;/a&gt; anyone?). I can&amp;#8217;t tell you how many times I&amp;#8217;ve clicked &amp;#8220;Last&amp;#8221; by accident.&lt;/p&gt;
&lt;p&gt;It would seem to me that visitors want to go to the next page far more frequently than they want to jump to the last. I think the pagination links should respect that.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Looks like they added a &amp;#8220;Next&amp;#8221; link. Well played.&lt;/p&gt;</description>
      <author>Pat Nakajima</author>
      <guid>/articles/ui-glitch-at-smashing-magazine.rss</guid>
      <pubDate>Thu, 05 Jun 2008 20:27:40 +0000</pubDate>
      <link>http://blog.patnakajima.com/articles/ui-glitch-at-smashing-magazine.rss</link>
    </item>
  </channel>
</rss>
