<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

 <title>The Garvin</title>
 <link href="http://thegarvin.com/atom.xml" rel="self"/>
 <link href="http://thegarvin.com/"/>
 <updated>2018-09-25T22:45:20+00:00</updated>
 <id>http://thegarvin.com/</id>
 <author>
   <name>The Garvin</name>
   <email>jim+blog@thegarvin.com</email>
 </author>

 
 <entry>
   <title>Dylan Hale: A Great Realtor in NC.</title>
   <link href="http://thegarvin.com/2014/08/04/review-of-dylan-hale-great-nc-realtor.html"/>
   <updated>2014-08-04T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2014/08/04/review-of-dylan-hale-great-nc-realtor</id>
   <content type="html">&lt;p&gt;If you’re in a rush, and you just want to know whether I’d recommend &lt;a href=&quot;http://gorealty.biz/home/go-cary/dylan-hale/&quot;&gt;Dylan
Hale&lt;/a&gt; as a broker/agent for buying
a home, the answer is: Yes.  Absolutely, without hesitation, reservation, or any
caveat whatsoever: &lt;em&gt;Yes&lt;/em&gt;.  Dylan is an intelligent, honest, hard-working human
being that also happens to be a very good Realtor with a very good team behind
him.&lt;/p&gt;

&lt;h2 id=&quot;heres-the-longer-version&quot;&gt;Here’s the longer version.&lt;/h2&gt;

&lt;p&gt;My wife and I were living in Northern VA, and we decided to relocate to the
Research Triangle of NC.  Our past experiences with buyer’s agents weren’t
stellar, and I wanted to try buying our next home without one.  This is just to tell you that, at the
beginning of this story: I didn’t want a realtor, I thought I could do
everything without a realtor (saving 3%!), and I was pretty sure I would be
irritated by any realtor that we’d sign up with - all the while wondering “How is
unlocking doors to houses worth 3% commission?”&lt;/p&gt;

&lt;p&gt;My wife wasn’t necessarily on board with the idea. She humored me, though, and began the process of finding candidate homes
using sites like Zillow.  She’d see a house that fit our criteria and fill in
the little contact form on the side-bar to schedule a walk-through on next
trip down to the area.  Most of the realtors would respond by the end of the day
via email.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;One of the listing agents called her within 3 minutes.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;My wife was the one that answered the phone and spoke to Dylan initially.  After
the phone call ended, she reported a very nice conversation with a realtor that
wasn’t pushy at all, and just wanted to let us know he was happy to help us out
whenever we made a trip down.  My wife and Dylan also talked about the issue of
not having a buyer’s agent, and of COURSE he offered to represent us (it’s his
job, after all!), but she knew I was pretty “enthusiastic” about not getting
tied to a potentially lame realtor - so she just politely indicated that we’d
discuss it and let him know.&lt;/p&gt;

&lt;p&gt;Oh, and discuss it we did!  “We haven’t done any research! - This is just some
guy that happened to be the first one to call!” - and right there was the first
chink in my defenses: this guy called within minutes. He’s clearly on top of his
business.  “Ok, credit where credit is due - but what else do we know about him?
That could’ve been an anomaly!”  So my wife, being the marriage-judo master that
she is, agreed that I should vet him further.&lt;/p&gt;

&lt;p&gt;So, I called Dylan and introduced myself, and I told him about my concerns and
hesitations and he was very understanding, and when I asked for references from
previous clients, he paused for about 1 second, and then said “Yea, sure, no
problem.  I’ll get a list to you today.”  And he did.&lt;/p&gt;

&lt;p&gt;I followed up with the people on his list and got emails and phone calls for
responses.  The responses that I got were not just “+1 would use again” - they
were heartfelt expressions of gladness and relief that they had used Dylan as
their realtor.  With each reply, I was more surprised at the words being used to
describe their experience with a realtor.  They were certainly not words I would
have ever thought attributable to one.  Words like “Hardest Working”,
“work-horse”, “integrity”, “reliability”, “never felt neglected”, “on the ball
every step of the way”, etc, etc.&lt;/p&gt;

&lt;p&gt;My wife and I discussed it more, and decided to take Dylan up on his offer to
walk through houses.  We told him about our schedule and that we’d be driving
down on Sunday so that we’d have all of Monday, Tuesday and Wednesday to look at
houses.  He explained that he’d make himself available for us during that period
so that we’d be able to see all of the houses and areas that we needed to see.&lt;/p&gt;

&lt;p&gt;On Sunday, as we drove down to NC, my mobile phone rang.  It was Dylan.  He
asked what time we’d be getting into town, and offered to begin showing us
houses that afternoon.  We hadn’t assumed he’d be available on Sunday - but he
put it out there because he knew were had a lot to cover in a limited amount of
time.&lt;/p&gt;

&lt;p&gt;Whatever concerns I had about Dylan being dependable and reliable were quickly
eroding.&lt;/p&gt;

&lt;p&gt;Over the course of the next few days, we proceeded with a routine of waking up,
getting coffee, meeting Dylan, seeing houses, eating lunch, seeing more houses,
and finally getting dinner and going back to our hotel room to digest the day’s
events.  Every night, we’d receive emails from Dylan with more listings, and
we’d whittle down the list of houses we kept in a spreadsheet.&lt;/p&gt;

&lt;p&gt;By the end of the 3 days, we were exhausted - but we had found the right house
for us, and we did submit an offer, and Dylan was included on the offer as our
agent.&lt;/p&gt;

&lt;p&gt;Whatever concerns I had about Dylan being hard-working or dedicated were gone.&lt;/p&gt;

&lt;p&gt;Over the next few weeks we proceeded through negotiation, inspections, more
negotiations, and all the other things that wrack the nerves during the
home-buying process.  Dylan and his amazing team were on-point for EVERYTHING.&lt;/p&gt;

&lt;p&gt;They arranged inspection, and because I couldn’t be there, Dylan was present on
my behalf.  For all of the issues that we learned during inspection, Dylan
reached out to his network of contacts to get answers, estimates, and expert
opinions on various items.&lt;/p&gt;

&lt;p&gt;We secured our loan with &lt;a href=&quot;http://onqfinancial.com/our-firm/mortgage-consultants/davis-orebaugh/&quot;&gt;Davis Orebaugh at OnQ
Financial&lt;/a&gt;.
He and his team met the bar that Dylan had set for service, professionalism,
and just being &lt;em&gt;decent human beings&lt;/em&gt;.  I can’t stress that part enough: these
were all &lt;em&gt;good&lt;/em&gt; people.  Also, we got great loan terms - much better terms than
we were able to get through other lenders.  So, you know, there’s that.&lt;/p&gt;

&lt;p&gt;When I finally traveled down to NC for the closing, the whole team was there.  I
met &lt;a href=&quot;https://www.facebook.com/ChrisMannLaw&quot;&gt;Chris Mann&lt;/a&gt;, the closing attorney.
He whipped us through the signing process of a massive stack of papers,
explaining everything along the way, answering any questions I might’ve had.&lt;/p&gt;

&lt;p&gt;So, it’s all said and done.  We moved in to our new home about two months ago
and I’m writing this review on my blog, because the 150 characters Zillow
affords wasn’t enough.&lt;/p&gt;

&lt;p&gt;Whatever concerns I ever had about Dylan being the right choice for us, are
gone.&lt;/p&gt;

&lt;p&gt;We consider ourselves lucky to have met Dylan and worked with him, and
his team.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>The Disciplined Programmer</title>
   <link href="http://thegarvin.com/2012/01/28/the-disciplined-programmer.html"/>
   <updated>2012-01-28T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2012/01/28/the-disciplined-programmer</id>
   <content type="html">&lt;p&gt;When you run across a project that suffers from things like messy code, poor
design, or lack of tests, there are two possibilities: The first is that the
responsible party was so inexperienced that they had no idea they were making
a mess.  It honestly never occurred to them that they were doing a poor job.  The
second possibility is that the responsible party knew they were writing messy
code, they knew they weren’t being thoughtful about the design, and despite
knowing all about TDD, they still skipped writing tests.  This second group is
one that I think most developers fall into at some point.&lt;/p&gt;

&lt;p&gt;If you’ve ever explained a messy code base, or terrible test coverage with this
excuse:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;We had no time, we had to get it done ASAP.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;then this post is for you.  We’ve all felt the pressure of “ASAP”.  We’ve all read
&lt;a href=&quot;http://www.amazon.com/gp/product/0307463745/ref=as_li_ss_tl?ie=UTF8&amp;amp;tag=thegarvincom-20&amp;amp;linkCode=as2&amp;amp;camp=1789&amp;amp;creative=390957&amp;amp;creativeASIN=0307463745&quot;&gt;Rework&lt;/a&gt;,
which convinced us that “ASAP” is poison.  We know that when &lt;em&gt;everything is
ASAP&lt;/em&gt;, then &lt;em&gt;NOTHING&lt;/em&gt; is.  And we know that when we rush to get things done
ASAP, we inevitably cut corners that hurt us in the long run: We skip writing
tests.  We commit messy code that we’re embarrassed by.  We trade moments of
quiet thinking about the problem for frenzied keyboard clacking, as if
words-per-minute could ever make up for a deficit in thoughtful design.  We do
all this despite knowing it’s wrong.&lt;/p&gt;

&lt;h2 id=&quot;so-why-do-we-do-it&quot;&gt;So why do we do it?&lt;/h2&gt;

&lt;p&gt;I believe it’s one of those classic disconnects between what we intuitively feel
versus what intellectually know.  Intuitively, we feel like we’re getting things
done faster when we blast through code and don’t take the time to TDD.
Intellectually, &lt;a href=&quot;http://research.microsoft.com/en-us/groups/ese/nagappan_tdd.pdf&quot;&gt;we
know&lt;/a&gt; that TDD
reduces software defects and speeds up development (in the long run), and that thoughtful
design yields cascading benefits that permeate entire systems.&lt;/p&gt;

&lt;p&gt;Most programmers probably have the same harmful intuition when stressed.
However, given the same stressful circumstances, some programmers will behave
according to their intuition, and others will behave according to what they know
intellectually.  Why?&lt;/p&gt;

&lt;h2 id=&quot;discipline&quot;&gt;Discipline&lt;/h2&gt;

&lt;p&gt;It is the unsexiest of programmer attributes.  I think of how many times I’ve
heard people talk about the exciting elements of programming: solving hard
problems, writing elegant “beautiful” code, being &lt;em&gt;creative&lt;/em&gt;, automating away
inefficiencies and taming the techno-beast.  These things come up when trying to
convince others that we are passionate about our craft in a job interview, or
explaining why our job doesn’t suck to children at Career Day. But how often have
you heard someone talk about methodicalness, or the virtue of embracing
routine, or the necessity of regular and critical reflection? What about the
discipline that is required by all of those things?&lt;/p&gt;

&lt;p&gt;The most productive programmers I know comprise their daily routine from a series
of repeatable work flows.  They are methodical.  Even creative tasks are
performed in a methodical manner.  Their routines become habit, and they can
sense when the routine needs adjustment - like a wobbly wheel that’s out of
alignment.  In addition to being generally productive, they also tend to produce
clean, thoughtful, tested code.&lt;/p&gt;

&lt;p&gt;Discipline is not glamorous. I doubt we’ll see “disciplined programmer” supplant
“ninja” or “rock star” in job postings any time soon.  Nonetheless, I’ll be
focusing on it more as a deliberate addition to my programmer psyche, and
encouraging it more in others - especially those who shout to others from atop
their heap of disastrous code &lt;em&gt;“Sorry about this mess, I was in a rush!”&lt;/em&gt;&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>The M in DOM stands for Model</title>
   <link href="http://thegarvin.com/2011/09/07/the-m-in-dom-stands-for-model.html"/>
   <updated>2011-09-07T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2011/09/07/the-m-in-dom-stands-for-model</id>
   <content type="html">&lt;p&gt;This is a response to a post by my friend &lt;a href=&quot;http://twitter.com/#!/metaskills&quot;&gt;Ken
Collins&lt;/a&gt;: &lt;a href=&quot;http://metaskills.net/2011/09/06/how-do-you-encapsulate-your-javascript/&quot;&gt;“How Do You Encapsulate
Your
Javascript”&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I agree 100% with Ken that poorly organized code, code that litters on the
global namespace, and code written such that it can’t be reused is a sign of
amateurness.  However, I disagree that jQuery plays a role in leading developers
astray regarding good software design principles.&lt;/p&gt;

&lt;p&gt;Part of Ken’s criticism is that jQuery doesn’t sheperd new developers “into
learning some sort of way to encapsulate their object behavior.” Why should it?
jQuery isn’t relevant to the problem space of modeling domain objects.
Javascript, the language, provides those facilitates.  You can model complicated
behavior all day and night using nothing more than core Javascript.  Even
so, most developers find the core facilities of Javascript too foreign, or too
basic for building their applications.  Thankfully, plenty of
&lt;a href=&quot;http://documentcloud.github.com/backbone/&quot;&gt;great&lt;/a&gt;
&lt;a href=&quot;http://batmanjs.org/&quot;&gt;libraries&lt;/a&gt;/&lt;a href=&quot;http://knockoutjs.com/&quot;&gt;frameworks&lt;/a&gt; have been
invented to address that need.&lt;/p&gt;

&lt;p&gt;jQuery is a library for working with the DOM and normalizing all the annoying
variations across browser specific APIs.  The way I like to think of it is: Your
web application always has at least one model: the Document.  Like any other
object, it has state (e.g. the node tree, document properties) and behavior
(e.g. adding and removing nodes).  jQuery provides the interface through which
you work with that object.  jQuery is &lt;em&gt;not&lt;/em&gt; a library for helping you model other
parts of your application.&lt;/p&gt;

&lt;p&gt;With that in mind, I think writing a class that gives you another model on top
of the DOM, just so you can ape classical OO in Javascript, is a smell.  As an
illustration, I’ll rewrite Ken’s example using the &lt;a href=&quot;/2009/10/28/clearer-code-with-jquery-micro-plugins.html&quot;&gt;jQuery plugin
approach&lt;/a&gt;.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-coffeescript&quot; data-lang=&quot;coffeescript&quot;&gt;  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;flash&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;content&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;null&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;htmlClass&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;notice&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;

    &lt;span class=&quot;nx&quot;&gt;flashElement&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;find&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;div.flash&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;removeClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;notice alert&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
      &lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;addClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;htmlClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;mobile&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;silentScroll&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;flashElement&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;toggle&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;With the &lt;code class=&quot;highlighter-rouge&quot;&gt;$.fn.flash&lt;/code&gt; plugin defined, we can use it to set the flash on any page:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-coffeescript&quot; data-lang=&quot;coffeescript&quot;&gt;  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;flash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;OMG it worked!!! &amp;lt;3 &amp;lt;3 &amp;lt;3&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;# sets and shows flash notice&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;flash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Broken. (._.)&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;s&quot;&gt;&quot;alert&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;    &lt;span class=&quot;c1&quot;&gt;# sets and shows flash alert&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;currentPage&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;na&quot;&gt;flash&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;                            &lt;span class=&quot;c1&quot;&gt;# clears and hides flash&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;I believe it has feature parity with Ken’s example and is just as reusable, but
has the advantage of being idiomatic jQuery that’s simpler and has fewer
dependencies.&lt;/p&gt;

&lt;p&gt;To explain the phenomenon that so much Javascript is written so poorly by so
many, I hold the (relatively uncontroversial) theory that: most developers write
Javascript without actually learning it.  Heck, I myself didn’t actually read my
first Javascript book until after I had already spent a few years barely
grokking the occasional Javascript snippet and making things barely work by
sheer coincidence.&lt;/p&gt;

&lt;p&gt;On the flip side: I’ve seen well functioning, non-trivial, and well tested
Javascript applications where the primary unit of reuse was the jQuery plugin,
and encapsulation was had via closures.&lt;/p&gt;

&lt;p&gt;The classical OO approach is not the only game in town for good software design.
Don’t forget that the DOM is already a model that has its own state and
behavior, and jQuery plugins are your best bet for creating reusable code with
naturally occurring encapsulation via scoped variables and closures.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Why doesn't your business use MongoDB?</title>
   <link href="http://thegarvin.com/2011/02/25/why-doesn-t-your-business-use-mongodb.html"/>
   <updated>2011-02-25T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2011/02/25/why-doesn-t-your-business-use-mongodb?</id>
   <content type="html">&lt;p&gt;&lt;a href=&quot;http://twitter.com/#!/nathenharvey&quot;&gt;Nathen Harvey&lt;/a&gt; invited me to speak at the &lt;a href=&quot;http://www.meetup.com/Washington-DC-MongoDB-Users-Group/&quot;&gt;Washington DC MongoDB Users Group&lt;/a&gt; this month, and the purpose of the talk was to raise the question: “Why doesn’t your business use MongoDB?”&lt;/p&gt;

&lt;p&gt;A few people asked me to post slides from the talk, but they would’ve been difficult to derive meaning from without the accompanying talk and discussion, so I added sticky notes to the slides to help with narration.  I also added a post-meetup notes slide with a few links.&lt;/p&gt;

&lt;div style=&quot;text-align:center&quot;&gt;
  &lt;a href=&quot;/downloads/FebMongoUserGroupPresentation.pdf&quot; style=&quot;text-align:center&quot;&gt;
    &lt;img src=&quot;/images/pdf_icon.png&quot; style=&quot;width:96px;height:96px;&quot; title=&quot;Why isn't your business using MongoDB?&quot; alt=&quot;Presentation Slides&quot; /&gt;&lt;br /&gt;Download&lt;/a&gt;
&lt;/div&gt;

&lt;h2 id=&quot;mongodb-18rc0&quot;&gt;MongoDB 1.8rc0!&lt;/h2&gt;

&lt;p&gt;As fortune would have it, 10gen pushed out the release candidate for &lt;a href=&quot;http://www.mongodb.org/display/DOCS/1.8+Release+Notes&quot;&gt;MongoDB 1.8&lt;/a&gt; on the same day as the meetup, so we all got to hug and cry (happy tears) as a group.  The big news here is that MongoDB can now employ write-ahead journaling.&lt;/p&gt;

&lt;div style=&quot;text-align:center;margin-bottom:1em&quot;&gt;
  &lt;img src=&quot;/images/maxdurability.png&quot; title=&quot;Still a few more uses before it's tired.&quot; alt=&quot;Maximum Durability&quot; /&gt;
&lt;/div&gt;

&lt;p&gt;That’s great news for the single-server durability hold-outs, as they may now comfortably proceed with their full embrace of MongoDB.&lt;/p&gt;
</content>
 </entry>
 
 <entry>
   <title>Tips For Learning Vim</title>
   <link href="http://thegarvin.com/2010/08/04/tips-for-learning-vim.html"/>
   <updated>2010-08-04T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2010/08/04/tips-for-learning-vim</id>
   <content type="html">&lt;p&gt;Yehuda recently wrote about his &lt;a href=&quot;http://yehudakatz.com/2010/07/29/everyone-who-tried-to-convince-me-to-use-vim-was-wrong/&quot;&gt;trials in trying to switch to Vim&lt;/a&gt;, the failed approaches, and what finally did work for him.  I thought this was great, because different people learn in different ways, and the unique approach someone else comes up with might work well for you too.  In that spirit, I wanted to share a few methods I used while learning Vim that worked well for me.&lt;/p&gt;

&lt;p&gt;Separated into their own posts for digestibility, and in no particular order…&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;switching-from-arrows-to-hjkl.html&quot;&gt;Switching from the arrows to &lt;code class=&quot;highlighter-rouge&quot;&gt;hjkl&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;remap-caps-lock-to-control.html&quot;&gt;Remap Caps Lock to Control&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;dont-start-from-scratch.html&quot;&gt;Don’t start from scratch&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;dont-forget-the-built-in-help&quot;&gt;Don’t forget the built in help!&lt;/h3&gt;

&lt;p&gt;Vim has a ridiculously useful help system built in.  This may seem obvious, but I always forget this fact and rush off to google to figure something out, and the search will regularly lead me back to the Vim docs.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-sh&quot; data-lang=&quot;sh&quot;&gt;  :help&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;vim-links&quot;&gt;Vim links&lt;/h3&gt;

&lt;p&gt;Here’s a few resources that helped me along:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://www.amazon.com/Learning-Vim-Editors-Arnold-Robbins/dp/059652983X&quot;&gt;Learning vi and Vim&lt;/a&gt; O’Reilly book&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://dailyvim.blogspot.com/&quot;&gt;Daily Vim tips&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://vim.wikia.com/wiki/Best_Vim_Tips&quot;&gt;Best Vim Tips on vim.wikia.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I highly recommend the O’Reilly book.  It’s big, but it’s a worthwhile investment if you’re going to make Vim your One True Editor.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Switching From Arrows To hjkl</title>
   <link href="http://thegarvin.com/2010/08/04/switching-from-arrows-to-hjkl.html"/>
   <updated>2010-08-04T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2010/08/04/switching-from-arrows-to-hjkl</id>
   <content type="html">&lt;p&gt;(Part of the &lt;a href=&quot;tips-for-learning-vim.html&quot;&gt;Tips For Learning Vim&lt;/a&gt; series.)&lt;/p&gt;

&lt;p&gt;Moving your hand off the home row to use the arrow keys is a sin in Vim, but getting used to the &lt;code class=&quot;highlighter-rouge&quot;&gt;hjkl&lt;/code&gt; keys for movement was a HUGE pain for me.  In fact, I used vim for &lt;em&gt;years&lt;/em&gt; without kicking the arrow key habit.  I finally kicked the habit with the help of some focused finger training.&lt;/p&gt;

&lt;p&gt;The goal of this exercise is to build new neural pathways so that your brain no longer has to go through the cognitive effort of translating your desire to have the cursor move down by one line into pressing the letter &lt;code class=&quot;highlighter-rouge&quot;&gt;j&lt;/code&gt; on the keyboard.  You want your brain to optimize for the relationship between your will and your fine motor movements.  In fewer words: you want to build muscle memory.&lt;/p&gt;

&lt;p&gt;You might notice that the exercise focuses on training the opposite pairs (up &amp;amp; down, then left &amp;amp; right) instead of all of the directions at once.  This reinforces the behavior where you group you vertical and horizontal movements rather than trying to interleave the two (creating diagonal cursor movements, which will be slower and probably not what you want to do in Vim anyways).&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Open a file with some text in it and put the cursor somewhere in the middle.&lt;/li&gt;
  &lt;li&gt;Rest your right hand on the home row (index finger on &lt;code class=&quot;highlighter-rouge&quot;&gt;j&lt;/code&gt;, middle finger on &lt;code class=&quot;highlighter-rouge&quot;&gt;k&lt;/code&gt;)&lt;/li&gt;
  &lt;li&gt;Now just rapidly alternate between pressing the &lt;code class=&quot;highlighter-rouge&quot;&gt;j&lt;/code&gt; and &lt;code class=&quot;highlighter-rouge&quot;&gt;k&lt;/code&gt; keys.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;As you press the keys, the cursor will move up and down.  Just stare at it while you press the keys.  Let your brain soak it in.  Try to forget the keys you’re pressing, and just feel the shape of your hands on the keys, the way your fingers feel while you make the cursor go up and down.  Sounds goofy, but it should help build muscle memory.&lt;/p&gt;

&lt;p&gt;Then repeat the exercise with your index finger on &lt;code class=&quot;highlighter-rouge&quot;&gt;h&lt;/code&gt; and your ring finger on &lt;code class=&quot;highlighter-rouge&quot;&gt;l&lt;/code&gt;.  The cursor moves left and right.  Just get your fingers going then stare at the cursor movement while it wiggles back and forth.  Let your brain soak it in.&lt;/p&gt;

&lt;p&gt;Then start doing a several key presses on each side: &lt;code class=&quot;highlighter-rouge&quot;&gt;jjjjkkkkjjjjkkkk&lt;/code&gt;, &lt;code class=&quot;highlighter-rouge&quot;&gt;hhhhllllhhhhllll&lt;/code&gt; and do that over and over.&lt;/p&gt;

&lt;p&gt;The last ingredient is to avoid using the arrow keys while you are coding.  For me, just the act of moving my right hand away from the home row annoyed me enough to remind me that I should instead use &lt;code class=&quot;highlighter-rouge&quot;&gt;hjkl&lt;/code&gt; keys.&lt;/p&gt;

&lt;h3 id=&quot;an-approach-that-didnt-work-so-well-for-me&quot;&gt;An approach that didn’t work so well for me&lt;/h3&gt;

&lt;p&gt;I also tried using mnemonics: &lt;code class=&quot;highlighter-rouge&quot;&gt;hjkl&lt;/code&gt; + “left, down, up, right” = “heft, jown, kup, light”.&lt;/p&gt;

&lt;p&gt;So if I needed to move the cursor down by 3 lines, I’d decipher in my head that “down” became “jown”, which started with a &lt;code class=&quot;highlighter-rouge&quot;&gt;j&lt;/code&gt;, so I need to press &lt;code class=&quot;highlighter-rouge&quot;&gt;j&lt;/code&gt; three times.  This was slow, and it sucked, and my friends had endless hours of amusement watching me use my mental decoder ring just to move around my editor.&lt;/p&gt;

&lt;h3 id=&quot;fringe-benefits-of-using-hjkl&quot;&gt;Fringe Benefits of using &lt;code class=&quot;highlighter-rouge&quot;&gt;hjkl&lt;/code&gt;&lt;/h3&gt;

&lt;p&gt;After you get used to &lt;code class=&quot;highlighter-rouge&quot;&gt;hjkl&lt;/code&gt; movement, you can enjoy their use in other applications.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Gmail - Enable shortcut keys, then use &lt;code class=&quot;highlighter-rouge&quot;&gt;jk&lt;/code&gt; to move the selection arrow up and down your inbox.&lt;/li&gt;
  &lt;li&gt;Any browser with a Vim-like plugin - use &lt;code class=&quot;highlighter-rouge&quot;&gt;hjkl&lt;/code&gt; to scroll around&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Chrome I use the &lt;a href=&quot;https://chrome.google.com/extensions/detail/dbepggeogbaibhgnhhndojpepiihcmeb&quot;&gt;Vimium extension&lt;/a&gt; which has a few great features.&lt;/p&gt;

&lt;p&gt;There are extensions for Safari and Firefox as well.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Remap Caps Lock to Control</title>
   <link href="http://thegarvin.com/2010/08/04/remap-caps-lock-to-control.html"/>
   <updated>2010-08-04T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2010/08/04/remap-caps-lock-to-control</id>
   <content type="html">&lt;p&gt;(Part of the &lt;a href=&quot;tips-for-learning-vim.html&quot;&gt;Tips For Learning Vim&lt;/a&gt; series.)&lt;/p&gt;

&lt;p&gt;This is a popular thing to do for people that use editors that rely on the control key for various functions.  The Caps Lock key is big, it’s in an easy to access and complementary location to other modifier keys, and you weren’t using it for anything anyways.  It’s not Vim specific, but I definitely think it makes using Vim more comfortable.  It’s easy to configure on Mac OS X.  Just open System Preferences and search for “reset modifier keys”.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/remap-caps-lock-system-prefs.jpg&quot; alt=&quot;&amp;quot;Remap Caps Lock on Mac OS X&amp;quot;&quot; /&gt;&lt;/p&gt;

&lt;p&gt;You can see in the screen shot that I disabled the original control key to speed up the retraining of my brain.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>Don't Start From Scratch</title>
   <link href="http://thegarvin.com/2010/08/04/dont-start-from-scratch.html"/>
   <updated>2010-08-04T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2010/08/04/dont-start-from-scratch</id>
   <content type="html">&lt;p&gt;(Part of the &lt;a href=&quot;tips-for-learning-vim.html&quot;&gt;Tips For Learning Vim&lt;/a&gt; series.)&lt;/p&gt;

&lt;p&gt;Some people might like the idea of starting with a blank slate for their Vim config, and then adding as they go, and I see the appeal in that, I get that, and (to quote Gary Vaynerchuck) I respect that.&lt;/p&gt;

&lt;p&gt;I’m not a patient person though.  I want full Vim fabulousness, and I want it now.&lt;/p&gt;

&lt;p&gt;A bunch of veteran Vim users have already spent lots of their time cultivating Vim configs that make Vim behave in useful and magical ways.  I used one of those configurations as a starting point and tailored it from there.  This made a lot of sense for me and helped make me more productive sooner.&lt;/p&gt;

&lt;p&gt;The few people I’ve helped switch to Vim have started by forking my &lt;a href=&quot;http://github.com/coderifous/dotfiles/commits/master&quot;&gt;dotfiles repository&lt;/a&gt; just to leverage the vim config that’s in there.  We shared a Textmate background, and we were all doing ruby development, so it made a lot of sense.  Since we started off with forks, it was easy to use github to share additions and tweaks we made over time.  We’d send each other messages like “Hey, I just added a plugin that does snippets just like textmate - do a pull!” and everyone would benefit for it.  Good times.&lt;/p&gt;

</content>
 </entry>
 
 <entry>
   <title>"Git is just too hard"</title>
   <link href="http://thegarvin.com/2009/12/14/git-is-too-hard.html"/>
   <updated>2009-12-14T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2009/12/14/git-is-too-hard</id>
   <content type="html">&lt;p&gt;&lt;img src=&quot;/images/git-ffuu.png&quot; alt=&quot;&amp;quot;Git FFUU&amp;quot;&quot; title=&quot;Don't let this happen to you.&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Here’s the sentiment that’s been delivered to me on several occasions by different people:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;“Git is too hard, and Subversion is good enough.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It saddens me when I hear this.  Why does it sadden me?  Because some very smart developers are missing out on a great tool that can improve how they work, and enable cleaner project histories.&lt;/p&gt;

&lt;h2 id=&quot;basic-git-usage-is-easy&quot;&gt;&lt;em&gt;Basic&lt;/em&gt; Git usage is easy&lt;/h2&gt;

&lt;p&gt;I’d like to dispense with the &lt;em&gt;“Git is too hard”&lt;/em&gt; complaint.  As I write this, &lt;a href=&quot;http://github.com&quot;&gt;Github’s home page&lt;/a&gt; says that they have 155,000 coders using their service. Even if a significant portion of that number is virtual/duplicate accounts, or people signed up to Github despite loathing Git, you still have a huge mass of developers that apparently don’t think Git is too hard.  That’s just counting Git users on Github.  If they can figure Git out, you probably can too.&lt;/p&gt;

&lt;p&gt;That’s my argumentum ad numerum: &lt;em&gt;one hundred thousand developers can’t be wrong!&lt;/em&gt;  But I don’t like it when people use logical fallacies on me, so I won’t use them on you.&lt;/p&gt;

&lt;p&gt;How might we objectively prove that Git is, in fact, not “too hard” when compared to Subversion?  Cold hard concrete example, I guess.&lt;/p&gt;

&lt;p&gt;Go look at the &lt;a href=&quot;http://git.or.cz/course/svn.html&quot;&gt;Git-SVN Crash Course&lt;/a&gt;, where you’ll see examples of equivalent commands in Subversion and Git.  In many cases, the commands are nearly identical.  Consider the typical workflow:&lt;/p&gt;

&lt;h3 id=&quot;using-subversion&quot;&gt;Using Subversion:&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;  &lt;span class=&quot;c&quot;&gt;# get the code&lt;/span&gt;
  svn checkout http://whatever
  &lt;span class=&quot;c&quot;&gt;# ... make some changes, then commit them ...&lt;/span&gt;
  svn commit&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h3 id=&quot;using-git&quot;&gt;Using Git:&lt;/h3&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-bash&quot; data-lang=&quot;bash&quot;&gt;  &lt;span class=&quot;c&quot;&gt;# get the code&lt;/span&gt;
  git clone git://whatever
  &lt;span class=&quot;c&quot;&gt;# ... make some changes, then commit them ...&lt;/span&gt;
  git commit &lt;span class=&quot;nt&quot;&gt;-a&lt;/span&gt;
  &lt;span class=&quot;c&quot;&gt;# optionally share your commits&lt;/span&gt;
  git push&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;That’s the basic retrieve-edit-commit cycle that you do in either Subversion or Git 90% of the time.  Your first hint that something is different is with the &lt;code class=&quot;highlighter-rouge&quot;&gt;git push&lt;/code&gt; command.  One of the key features of Git is that you can do things to commits before you share them.  If that concept makes no sense to you, let it serve as a clue to you that you &lt;em&gt;might&lt;/em&gt; be missing out on something powerful.  Being able to make commits without sharing them with the world is foundational to many of Git’s more powerful features.&lt;/p&gt;

&lt;p&gt;Those powerful features of Git are the ones that you don’t have to understand right away.  The stash, the index, rebasing, forking and adding different remotes - these are all things that you don’t need to understand on your first day.  You can do your basic Subversion-style work flow easily with Git, and learn the advanced stuff as you go; just like everything else you’ve ever learned.&lt;/p&gt;

&lt;h2 id=&quot;once-you-understand-git-subversion-is-obsolete&quot;&gt;Once you understand Git, Subversion is obsolete&lt;/h2&gt;

&lt;p&gt;Subversion is only “good enough” until you learn Git.  It’s true.  I can’t think of any situation where I’d choose to use Subversion over Git.  Git can do everything Subversion can do (and better), but not vice versa.  Working with Subversion feels utterly primitive after using Git, and I’m definitely not the only one that thinks so.  In fact, &lt;a href=&quot;http://www.kernel.org/pub/software/scm/git/docs/git-svn.html&quot;&gt;git-svn&lt;/a&gt; was created so that Git users &lt;em&gt;stuck&lt;/em&gt; on a project using Subversion wouldn’t have to live without the glorious features that Git provides.&lt;/p&gt;

&lt;p&gt;Git is a better tool for the job, and a craftsman should use the best tools available.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://github.com/jcoglan/svn2git&quot;&gt;Make the switch&lt;/a&gt;.&lt;/p&gt;

&lt;h2 id=&quot;resources&quot;&gt;Resources&lt;/h2&gt;

&lt;p&gt;Here’s some resources that should be helpful for anyone learning and using Git:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;&lt;a href=&quot;http://gitready.com&quot;&gt;http://gitready.com&lt;/a&gt; - a great cookbook style reference.  Consult it early and often.  This is my favorite Git resource.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://book.git-scm.com/&quot;&gt;The Git Community Book&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://whygitisbetterthanx.com&quot;&gt;Why Git is better than Subversion&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://github.com/webmat/git_remote_branch&quot;&gt;git_remote_branch ruby gem&lt;/a&gt; - it gives you a command line utility that takes care of managing remote branches.&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;http://github.com/blog/564-hub-git-with-github&quot;&gt;git with github&lt;/a&gt; - a command line script which adds GitHub knowledge to a few git subcommands.&lt;/li&gt;
&lt;/ul&gt;
</content>
 </entry>
 
 <entry>
   <title>Clearer code with jQuery micro-plugins</title>
   <link href="http://thegarvin.com/2009/10/28/clearer-code-with-jquery-micro-plugins.html"/>
   <updated>2009-10-28T00:00:00+00:00</updated>
   <id>http://thegarvin.com/2009/10/28/clearer-code-with-jquery-micro-plugins</id>
   <content type="html">&lt;p&gt;Most non-trivial javascript applications need to do some work after the document
loads.  jQuery makes it easy to hook into that event, and lots of people use it
like this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// application code... ALL of it&lt;/span&gt;

    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;searchParameter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#search_form input[type=text]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;focus&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

    &lt;span class=&quot;c1&quot;&gt;// .. 200 lines later ...&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// ah, here's the code you need to tweak&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Maybe this is OK for really small apps, but when you’ve got a few hundred lines
of javascript milling around in there, you’ll eventually start to feel the pain.
You’ll try things like punctuating sections of code with comments, &lt;a href=&quot;http://google.com/search?q=comments+are+code+smell&quot;&gt;which we all
know is bad&lt;/a&gt;, or breaking your
&lt;code class=&quot;highlighter-rouge&quot;&gt;$(document).ready()&lt;/code&gt; calls up into a several &lt;code class=&quot;highlighter-rouge&quot;&gt;$(document).ready()&lt;/code&gt; calls, one after the other.
&lt;em&gt;Gross&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;One way to get high-level comprehension of our code is to break the unrelated
sections out into their own functions, and then call those functions from the
setup block.&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;initializeSearchForm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;initializeRowPointer&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;initializeThumbnailSizeSlider&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;initializeQueueStatuses&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// and so on...&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

  &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;initializeSearchForm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;searchParameter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#search_form input[type=text]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;focus&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// and all the other functions...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Now our setup block gives us a bird’s eye view of what’s going
on when the page loads, and we can easily jump to those function definitions to
see what’s going on and make changes.  That’s better, and it’s how I’ve been
doing it for a while, but using a pattern that &lt;a href=&quot;http://ryan.mcgeary.org/&quot;&gt;Ryan McGeary&lt;/a&gt;
came up with, we can make this code reveal more about what it’s doing and make
it easier to maintain by embracing some jQuery-ness.&lt;/p&gt;

&lt;h2 id=&quot;bring-in-the-micro-plugins&quot;&gt;Bring in the micro-plugins&lt;/h2&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;document&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;ready&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(){&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#search input[type=text]&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;searchForm&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#orders&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;selectableRows&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#slider&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;thumbnailSizeSlider&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;td.picture img&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;#queue_statuses .status&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;queueStatus&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;c1&quot;&gt;// and so on...&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;});&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// micro-plugin&lt;/span&gt;
  &lt;span class=&quot;nx&quot;&gt;$&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;searchForm&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;kd&quot;&gt;function&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
    &lt;span class=&quot;kd&quot;&gt;var&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nx&quot;&gt;searchParameter&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;val&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;term&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nx&quot;&gt;addClass&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;focus&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
    &lt;span class=&quot;k&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
  &lt;span class=&quot;p&quot;&gt;};&lt;/span&gt;

  &lt;span class=&quot;c1&quot;&gt;// and all the other micro-plugins...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;By rewriting our functions as jQuery plugins, we enjoy several advantages
over the former approach:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;We moved the selector up into the setup block where we can easily see and
  change it.  This gives us a better idea of what our code is doing, all
  from the comfort of our bird’s eye view.&lt;/li&gt;
  &lt;li&gt;It’s a jQuery plugin!  Any other developer that’s familiar with jQuery, but
  new to your code, will immediately appreciate the assumptions he can make
  about your implementation.&lt;/li&gt;
  &lt;li&gt;It’s a jQuery plugin!  It’s very easy to reuse, even if you don’t plan on it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’ve never written a jQuery plugin before, this should really
highlight how &lt;em&gt;simple&lt;/em&gt; it is.  There aren’t any framework hoops to jump through.
You just slap a function on &lt;code class=&quot;highlighter-rouge&quot;&gt;jQuery.fn&lt;/code&gt; and access the wrapped set via &lt;code class=&quot;highlighter-rouge&quot;&gt;this&lt;/code&gt;.
It’s the simplicity of jQuery’s plugin system that makes the micro-plugin
possible.&lt;/p&gt;

&lt;h2 id=&quot;what-is-this-tomfoolery-thats-just-a-plugin&quot;&gt;What is this tomfoolery!? That’s just a plugin!&lt;/h2&gt;

&lt;p&gt;Yea, so let’s clear up the distinction between a plugin and a micro-plugin. The
difference is the author’s intent when writing the code.  Regular jQuery plugins
are written with reuse and sharing as a primary goal.
Micro-plugins are created solely because they make your application code clearer
and easier to maintain, and without any intent to ever reuse or share the code.&lt;/p&gt;

&lt;p&gt;If you find yourself reusing a micro-plugin across projects, and it becomes
something generally useful, then you can document it, share it, and call
it a real plugin.&lt;/p&gt;
</content>
 </entry>
 

</feed>

