<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">

  <title><![CDATA[Caffeine-Powered Life]]></title>
  
  <link href="http://jarrettmeyer.com/" />
  <updated>2013-05-12T18:05:50-04:00</updated>
  <id>http://jarrettmeyer.com/</id>
  <author>
    <name><![CDATA[Jarrett Meyer]]></name>
    <email><![CDATA[jarrettmeyer@gmail.com]]></email>
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/jarrettmeyer" /><feedburner:info uri="jarrettmeyer" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry>
    <title type="html"><![CDATA[I Was Wrong About MSMVC]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/O52_d---Z8A/" />
    <updated>2013-04-03T00:00:00-04:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/04/03/i-was-wrong-about-msmvc</id>
    <content type="html">&lt;p&gt;It&amp;rsquo;s no secret that I am a fan of Ruby on Rails. Just a quick look back through my archives, my first Ruby post was on &lt;a href="http://jarrettmeyer.com/post/1008562370/running-through-the-ruby-koans"&gt;25 August 2010&lt;/a&gt;. Ruby has become my get-stuff-done language. I author web sites with it. I deploy with &lt;a href="https://github.com/capistrano/capistrano"&gt;Capistrano&lt;/a&gt;. I script with it.&lt;/p&gt;

&lt;p&gt;Today, I was talking through an MSMVC vs. Rails example: post a form, parse the form data, save some stuff to the database, dynamically generate and send an HTML-body email, redirect to a success page. I don&amp;rsquo;t think I&amp;rsquo;m too off base here. I understand that the same amount of computational &amp;ldquo;stuff&amp;rdquo; has to happen no matter what language and framework is used.&lt;/p&gt;

&lt;p&gt;The difference is how much is baked into the Rails framework vs. how much is still left as an execise for the reader in MSMVC. It was then that I realized I shouldn&amp;rsquo;t be comparing the two.&lt;/p&gt;

&lt;p&gt;&lt;img class="right" src="http://jarrettmeyer.com/images/content/2013/04-apr/frankenstein_monster.jpg" width="300" title="s monster" alt="Frankenstein"&gt;&lt;/p&gt;

&lt;p&gt;MSMVC is a skeleton. You have to add the organs, muscles, and everything else to create your creature. Many of these organs can be downloaded and installed through Nuget. By the time you&amp;rsquo;ve written as many solutions as I have, you probably have a library of bits and pieces checked into a repo that you can add at will. Some things, like EF Code First, require Visual Studio plugins to be installed, so that&amp;rsquo;s a little annoying. Add enough stuff to your skeleton, and you can have your very own Frankenstein&amp;rsquo;s monster of an application.&lt;/p&gt;

&lt;p&gt;Rails is also a skeleton. It also comes out of the box with vital organs and enough muscle to breathe, walk, and eat on its own. Active Record is set up and ready to go. Asset bundling is a good idea and included by default. &lt;a href="http://sass-lang.com/"&gt;SCSS&lt;/a&gt; and &lt;a href="http://coffeescript.org/"&gt;CoffeeScript&lt;/a&gt; support? Put two lines in your Gemfile. Done. Rails is already Frankenstein&amp;rsquo;s monster.&lt;/p&gt;

&lt;p&gt;Once I figured this out, I realized that MSMVC is actually really good skeleton. Someone needs to build an opinionated framework on top of MSMVC that makes MSMVC as easy and as configurable as Rails.&lt;/p&gt;

&lt;p&gt;Pick an ORM. NHibernate? Entity Framework? Do you go micro with Dapper? I only want to worry about POCO classes. Let me craft my own SQL if I want. You don&amp;rsquo;t have to support 100% of cases out there.&lt;/p&gt;

&lt;p&gt;Pick a DI tool: Structure Map, Ninject, Unity. Whatever, I don&amp;rsquo;t care. Just don&amp;rsquo;t make me think about it. If it&amp;rsquo;s done well, I don&amp;rsquo;t even want to see any IoC library-specific code. I just want a container that I configure.&lt;/p&gt;

&lt;p&gt;Make it stupid simple. Encourage rapid scaffolding. Understand nested resources. The entire stack needs to be testable out of the box. This includes running an in-memory web server, so I can test session values and routing considerations. Tests need to hit a real database, with setup and teardown methods able to run fixtures at test startup.&lt;/p&gt;

&lt;p&gt;But if I don&amp;rsquo;t like something, let me override an implementation with my own stuff. This means that you&amp;rsquo;ve got to use interfaces and abstract classes and make your methods virtual.&lt;/p&gt;

&lt;p&gt;Support easy testing. Out of the box, run an in-memory web server just using a &lt;code&gt;StringBuilder&lt;/code&gt; as the output stream. Add some assertions that help with testing MSMVC.&lt;/p&gt;

&lt;p&gt;Someone go do that.&lt;/p&gt;

&lt;p&gt;Oh wait, &lt;a href="http://mvc.fubu-project.org/"&gt;someone already did&lt;/a&gt;, and it&amp;rsquo;s a hell of a lot closer to the target than what MS put together.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/O52_d---Z8A" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/04/03/i-was-wrong-about-msmvc/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Not Your Father's Accounting System]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/jTvoDfqImbs/" />
    <updated>2013-03-21T21:06:00-04:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/03/21/not-your-fathers-accounting-system</id>
    <content type="html">&lt;p&gt;Today, I had a wonderful conversation about transactions and transactional integrity in the NoSQL world, especially with document databases. The most common example being a financial system where two (or more) inserts must be created and either succeed together or fail together.&lt;/p&gt;

&lt;p&gt;First of all, not all systems are equal, and this isn&amp;rsquo;t 2008. &lt;a href="http://ravendb.net/docs/client-api/advanced/transaction-support"&gt;RavenDB supports transactions&lt;/a&gt; out of the box. Hey look! &lt;a href="http://docs.mongodb.org/manual/faq/developers/#how-do-i-do-transactions-and-locking-in-mongodb"&gt;So does Mongo&lt;/a&gt;. So correct faulty data when you get the chance.&lt;/p&gt;

&lt;p&gt;But I want to keep going, because this is still a point worth making.&lt;/p&gt;

&lt;p&gt;In an accounting system, you have three types of Balance Sheet accounts: Assets, Liabilities, Equity. These accounts must always satisfy the conditions Assets = Liabilities + Equity. We also have two types of Profit &amp;amp; Loss accounts: Operating Revenue and Operating Expense.&lt;/p&gt;

&lt;p&gt;So let&amp;rsquo;s take a typical accounting system. You probably have data that looks something like this. You&amp;rsquo;d have much more info, of course, like in what order accounts should appear in a chart of accounts, etc. For now, this will suffice.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;ACCOUNTS
ID  NUMBER  TYPE  DESCRIPTION          BALANCE  LAST_POSTED
 1  100001  AS    Cash                 2000.00  2013-03-20 00:00:00
 2  100002  AS    Accounts Receivable   500.00  2013-03-20 00:00:00
 3  100003  AS    Inventory            1000.00  2013-03-20 00:00:00
 4  200001  LI    Accounts Payable      250.00  2013-03-20 00:00:00
 5  300001  EQ    Owner Equity         2500.00  2013-03-20 00:00:00
 6  300002  EQ    Retained Earnings     750.00  2013-03-20 00:00:00
 7  400001  OR    Sales                1000.00  2013-03-20 00:00:00
 8  500001  OE    Cost of Goods Sold    500.00  2013-03-20 00:00:00
 9  500002  OE    Discounts Given       100.00  2013-03-20 00:00:00
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For this purpose, we&amp;rsquo;ll ignore taxes, payroll, loans, etc. Real companies have to worry about them, but they won&amp;rsquo;t add to our discussion.&lt;/p&gt;

&lt;p&gt;When an order comes in, customer is charged. If you were doing accounting by hand, you&amp;rsquo;d probably write something like this.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;                      Dr.      Cr.       Ref.
Accounts Receivable   100.00             Order #100
    Sales                      100.00
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;And in good ol&amp;#8217; relational database world, you would want to ensure that both inserts. Happened simultaneously.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;JOURNAL ENTRIES
TIMESTAMP            TYPE  ACCOUNT_ID  AMOUNT  REF         POSTED_AT 
2013-03-20 10:00:00  DR    2           100.00  Order #100  NULL
2013-03-20 10:00:00  CR    7           100.00  Order #100  NULL
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Note that your table of accounts is not updated at this time, because no accounting system that I&amp;rsquo;m aware of posts balances immediately. You usually go through a trial balance process first, then post balances when you&amp;rsquo;re sure that everything balances. To get the current balance of an account, you must take the account balance then add or subtract the unposted journal entries.&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s also important to note that a journal entry affects &lt;em&gt;at least&lt;/em&gt; two accounts, but could affect more. Here&amp;rsquo;s another order, later that same day, but this person had a coupon. We would need to add an extra debit for Discounts Given.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;                      Dr.      Cr.       Ref.
Accounts Receivable    90.00             Order #101
Discounts Given        10.00
    Sales                      100.00
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;If we have to pay sales tax, this becomes four lines, because you would need to debit the liability account for Taxes Owed. At least in Europe, it would be 4 lines, because the sales tax is included in the price of the product. If something says 10,69&amp;euro;, then it will cost 10,69&amp;euro; to walk out of the store. In the United States, taxes are added after the fact, so most companies would add two lines: one for Taxes Collected and one for Taxes Owed. If it says, $9.99, then it will really cost you $10.69 to walk out of the store (at least in Indiana).&lt;/p&gt;

&lt;p&gt;The journal entry still balances. It should be obvious that this should become three rows inserted into our &lt;code&gt;JOURNAL_ENTRIES&lt;/code&gt; table.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;JOURNAL ENTRIES
TIMESTAMP            TYPE  ACCOUNT_ID  AMOUNT  REF         POSTED_AT 
2013-03-20 13:00:00  DR    2            90.00  Order #100  NULL
2013-03-20 13:00:00  DR    9            10.00  Order #100  NULL
2013-03-20 13:00:00  CR    7           100.00  Order #100  NULL
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Like so. Or five inserts if we have the tax thing to worry about.&lt;/p&gt;

&lt;h3&gt;Can I write for a Document DB the same as RDBMS?&lt;/h3&gt;

&lt;p&gt;Yes. We could create multiple inserts just like this.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
  Timestamp: 2013-03-20 10:00:00,
  Type: "DR",
  Account: {
    Id: Account/2,
    Description: "Accounts Receivable"
  },      
  Ref: "Order #100",
  PostedAt: null
},
{
  Timestamp: 2013-03-20 10:00:00,
  Type: "CR",
  Account: {
    Id: Account/7,
    Description: "Sales"
  },
  Amount: 100.00,
  Ref: "Order #100",
  PostedAt: null
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Sure, that works. But what&amp;rsquo;s the point? What have you really gained by doing this? You&amp;rsquo;re still thinking like you&amp;rsquo;re working with an RDBMS. You&amp;rsquo;re not.&lt;/p&gt;

&lt;h3&gt;Should I write for a Document DB the same as RDBMS?&lt;/h3&gt;

&lt;p&gt;No. I would claim that this operation, and most operations with a document database, should be a single insert.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
  Timestamp: 2013-03-20 10:00:00,
  Description: "Order Received",
  Order: Orders/100,
  PostedAt: null
  Debits: [{
    Account: {
      Id: Accounts/2,
      Description: "Accounts Receivable"
    },
    Amount: 100.00
  }],
  Credits: [{
    Account: {
      Id: Accounts/7,
      Description: "Sales"
    },
    Amount: 100.00
  }]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You have now rewritten the problem to leverage the capabilities of a document database. And now you have a fairly simple &lt;a href="http://en.wikipedia.org/wiki/MapReduce"&gt;Map-Reduce&lt;/a&gt; to find the current account balance. Our second example isn&amp;rsquo;t really so different, which is why we recognized that debits and credits should be arrays.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
  Timestamp: 2013-03-20 13:00:00,
  Description: "Order Received",
  Order: Orders/101,
  PostedAt: null
  Debits: [{
    Account: {
      Id: Accounts/2,
      Description: "Accounts Receivable"
    },
    Amount: 90.00
  }, {
    Account: {
      Id: Accounts/9,
      Description: "Discounts Given"
    },
    Amount: 10.00
  }],
  Credits: [{
    Account: {
      Id: Accounts/7,
      Description: "Sales"
    },
    Amount: 100.00
  }]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Next, we need to verify inventory. Again, we don&amp;rsquo;t really update inventory values. We create a series of inventory transactions that later get rolled up and posted. Just like accounts, the current inventory is equal to the quantity on hand plus the unposted adjustments.&lt;/p&gt;

&lt;p&gt;In RDBMS land, this would be 3&lt;em&gt;n&lt;/em&gt; inserts, where &lt;em&gt;n&lt;/em&gt; is number of line items on the invoice. For each line on the order, you&amp;rsquo;d have an inventory transaction and two journal entries. You would debit Cost of Goods Sold and credit Inventory.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;INVENTORY_TRANSACTIONS
TIMESTAMP            ITEM_ID  ADJ  REF                  POSTED_AT
2013-03-20 10:05:00  10       -2   Order #100, Line #1  NULL
2013-03-20 10:05:00  11       -1   Order #100, Line #2  NULL

JOURNAL_ENTRIES
TIMESTAMP            TYPE  ACCOUNT_ID  AMOUNT  REF                  POSTED_AT 
2013-03-20 10:05:00  DR    8            40.00  Order #100, Line #1  NULL
2013-03-20 10:05:00  CR    3            40.00  Order #100, Line #1  NULL
2013-03-20 10:05:00  DR    8            15.00  Order #100, Line #2  NULL
2013-03-20 10:05:00  CR    3            15.00  Order #100, Line #2  NULL
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;A simple two-line order requires six inserts that all must succeed or fail together.&lt;/p&gt;

&lt;p&gt;Once again, I would make this a single document, encapsulating all of this information. Also, I would probably copy a bit more data to the local document, because that is something that we&amp;rsquo;re comfortable with doing in a NoSQL world.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
  Timestamp: 2013-03-20 10:05:00,
  Description: "Order Released",
  Order: Orders/100,
  PostedAt: null,
  Debits: [{
    Account: {
      Id: Accounts/8,
      Description: "Cost of Goods Sold",          
    },
    Product: {
      Id: Products/10,
      Description: "Something Awesome",
      Line: 1,
      Quantity: 2
    },
    Amount: 40.00
  },{
    Account: {
      Id: Accounts/8,
      Description: "Cost of Goods Sold",          
    },
    Product: {
      Id: Products/11,
      Description: "Something Else Awesome",
      Line: 2,
      Quantity: 1
    },
    Amount: 15.00
  }],
  Credits: [{
    Account: {
      Id: Accounts/2,
      Description: "Inventory",          
    },
    Product: {
      Id: Products/10,
      Description: "Something Awesome",
      Line: 1,
      Quantity: 2
    },
    Amount: 40.00
  }, {
    Account: {
      Id: Accounts/2,
      Description: "Inventory",          
    },
    Product: {
      Id: Products/11,
      Description: "Something Else Awesome",
      Line: 2,
      Quantity: 1
    },
    Amount: 15.00
  }],
  InventoryAdjustments: [{
    Product: Products/10,
    Adjustment: -2
  },{
    Product: Products/11,
    Adjustment: -1
  }]
}
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Like a book about your company.&lt;/h3&gt;

&lt;p&gt;The series of journal entries you create, instead of being a series of disjointed things with foreign keys, becomes a meaningful, human-readable story. This is an incredibly powerful benefit. The data has &lt;strong&gt;machine&lt;/strong&gt; value, &lt;strong&gt;business&lt;/strong&gt; value, and &lt;strong&gt;human&lt;/strong&gt; value contexts. Typically, data in an RDBMS has machine value only. It&amp;rsquo;s not until it&amp;rsquo;s translated by code that its business value and human value are realized.&lt;/p&gt;

&lt;h3&gt;But what about transactions?&lt;/h3&gt;

&lt;p&gt;What about them? These databases satisfy &lt;a href="http://en.wikipedia.org/wiki/ACID"&gt;ACID&lt;/a&gt;. You don&amp;rsquo;t need transactions for single ops. When you find ways to redefine your problem as single-document operations, the whole idea of transactions just becomes (mostly) a waste.&lt;/p&gt;

&lt;p&gt;That doesn&amp;rsquo;t mean that we don&amp;rsquo;t need transactions. It just means that their importance is greatly diminished. When we roll up trial balances and post them, we want all of those updates to be a single transaction. Depending on the size of your company and the frequency that you post transactions, the trial balance can be an enormous undertaking. Large manufacturing firms with thousands of inventory items and massive sales volumes who post once per month can accrue &lt;em&gt;millions&lt;/em&gt; of unposted journal entries.&lt;/p&gt;

&lt;p&gt;The trial balance is a collection of all of the journal entries and inventory adjustments to be included in the post. Controllers had the ability to decide which transactions were to be posted. For each account, you know the starting balance, you apply all adjustments, and you know the ending balance.&lt;/p&gt;

&lt;p&gt;Hey! We just described another document. It&amp;rsquo;s a working trial balance.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
  Id: TrialBalances/100,
  CreatedAt: 2013-03-22 14:20:00,
  CreatedBy: {
    Id: Users/jmeyer,
    Name: "Jarrett Meyer"
  },
  PostedAt: null,
  JournalEntries: [
    JournalEntries/1700, 
    JournalEntries/1701, 
    JournalEntries/1702
  ],
  AccountBalances: [{
    Id: Accounts/1,
    StartingBalance: 1000.00,
    Adjustments: 260.00,
    EndingBalance: 1260.00 
  }, {
    // ... etc ...
  }]
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;With a document like this, you know exactly what is supposed to happen. You know exactly what journal entries are to be included. You know exactly every adjustment to be applied. So even if the posting transaction fails, you know exactly what you should look for. Every journal entry in the list should have a non-null &lt;code&gt;PostedAt&lt;/code&gt; value, and the account balances should all match their &lt;code&gt;EndingBalance&lt;/code&gt; value. If that&amp;rsquo;s not the pit of success, then I don&amp;rsquo;t know what is.&lt;/p&gt;

&lt;p&gt;Document databases. It&amp;rsquo;s your data. Only clearer.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/jTvoDfqImbs" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/03/21/not-your-fathers-accounting-system/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Why C# Needs Duck Typing]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/PTIXgLyPP-Q/" />
    <updated>2013-02-17T09:03:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/02/17/why-c-sharp-needs-duck-typing</id>
    <content type="html">&lt;p&gt;I was working on a .NET project that lacked a few unit tests. So, being the Boy Scout developer I am, I decided I would add the ones that seemed obvious. Since this was a web project, that meant interacting with an active web session. The good news is that the web session has been wrapped with an adapter. The bad news is that the .NET framework is missing some obvious-to-me hooks.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;HttpSessionStateBase.cs &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='csharp'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;abstract&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HttpSessionStateBase&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;ICollection&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;IEnumerable&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="c1"&gt;// snip&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;abstract&lt;/span&gt; &lt;span class="kt"&gt;object&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="c1"&gt;// snip&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Why isn&amp;rsquo;t the indexer encapsulated into it&amp;rsquo;s own interface? It&amp;rsquo;s just sitting out there, a property of the class definition. Basic key-value lookup seems like an appalling obvious &lt;a href="http://martinfowler.com/bliki/RoleInterface.html"&gt;role interface&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If it were its own interface, think about how easy it would be to jump back and forth from an in-memory &lt;code&gt;Dictionary&amp;lt;string, object&amp;gt;&lt;/code&gt; to a live session. What&amp;rsquo;s your backing data? Who cares? This would make what I&amp;rsquo;m doing a heck of a lot easier.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;IKeyValueStore.cs &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='csharp'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;interface&lt;/span&gt; &lt;span class="n"&gt;IKeyValueStore&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;TKey&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;TValue&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;TValue&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;TKey&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;set&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;This interface should be retroactively added to all .NET objects that support indexing. This pattern pops up all over the place in .NET, so why not explicitly call it out when you see it? I&amp;rsquo;d even add it to &lt;code&gt;System.String&lt;/code&gt; as an &lt;code&gt;IKeyValueStore&amp;lt;int, char&amp;gt;&lt;/code&gt;. Of course, the setter would throw a &lt;code&gt;NotImplementedException&lt;/code&gt; with a very nice explanation that .NET strings are immutable.&lt;/p&gt;

&lt;p&gt;This is not the same as an &lt;a href="http://msdn.microsoft.com/en-us/library/5tbh8a42.aspx"&gt;&lt;code&gt;IDictionary&amp;lt;KeyValuPair&amp;lt;TKey, TValue&amp;gt;&lt;/code&gt;&lt;/a&gt;, although dictionaries would also implement this interface. There&amp;rsquo;s a ton of extra stuff you need to make a dictionary &amp;mdash; stuff I&amp;rsquo;m just not interested in writing. Nor do I want to have throw a ton of &lt;code&gt;NotImplmentedException&lt;/code&gt; all over my codebase.&lt;/p&gt;

&lt;p&gt;So why would duck typing matter? We wouldn&amp;rsquo;t care about the explict interface definition. Instead, we&amp;rsquo;d just call the indexer. If it works, then great! If not, then throw a &lt;code&gt;NotImplementedException&lt;/code&gt;. In fact, this is &lt;a href="http://haacked.com/archive/2007/08/19/why-duck-typing-matters-to-c-developers.aspx"&gt;exactly how the &lt;code&gt;foreach&lt;/code&gt; keyword works&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In the end, I want to be able to jump back and forth between backing stores for the purposes of writing tests. This isn&amp;rsquo;t difficult, but it&amp;rsquo;s work I don&amp;rsquo;t feel like I should have to do because I want higher code quality.&lt;/p&gt;

&lt;p&gt;A &lt;a href="https://gist.github.com/jarrettmeyer/4971798"&gt;Gist of this code has been provided&lt;/a&gt;. For those of you keeping score at home, that&amp;rsquo;s &lt;strong&gt;6&lt;/strong&gt; classes to something that should be really simple in 2013.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/PTIXgLyPP-Q" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/02/17/why-c-sharp-needs-duck-typing/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Body Acceptance]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/I0csplglEVI/" />
    <updated>2013-02-10T06:11:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/02/10/body-acceptance</id>
    <content type="html">&lt;p&gt;I have now completed 10 weeks of CrossFit at &lt;a href="http://www.titanfit.com"&gt;TitanFit&lt;/a&gt;. I am getting stronger. I am working hard. I love it. I never knew there was a strong person inside this body. I am &lt;span style="letter-spacing:-2px;"&gt;thisclose&lt;/span&gt; to being able to do a real, unassisted pull-up. And the people are really encouraging.&lt;/p&gt;

&lt;p&gt;I have been logging all my workouts on &lt;a href="http://www.fitocracy.com"&gt;Fitocracy&lt;/a&gt;. Yes, I was doing the Fito thing before &lt;a href="http://blog.fitocracy.com/post/40498595371/getbulky-this-lady-just-won-miss-america-the"&gt;Miss America made it so popular&lt;/a&gt;. &lt;em&gt;Was that hipster enough?&lt;/em&gt; Talk about a lot of body-positive people.&lt;/p&gt;

&lt;p&gt;Last night, Meaghan and I went shopping. I need a new belt. I should get a suit. I don&amp;rsquo;t own a suit. Shouldn&amp;rsquo;t every man own a suit? I found one that I loved at Banana Republic. A nice, three-piece gray suit. It was quite the handsome affair.&lt;/p&gt;

&lt;p&gt;Tailored Slim Fit.&lt;/p&gt;

&lt;p&gt;Fuck.&lt;/p&gt;

&lt;p&gt;As I look around, all the pants are &amp;ldquo;Classic Straight&amp;rdquo;, &amp;ldquo;Slim Fit&amp;rdquo;, &amp;ldquo;Tailored Slim Fit&amp;rdquo; (wasn&amp;rsquo;t Slim enough), and &amp;ldquo;Matchstick&amp;rdquo;. What the fuck is Matchstick fit? I&amp;rsquo;m in the men&amp;rsquo;s section, right? Yes, I am. Oh, they don&amp;rsquo;t sell clothes I can wear. Isn&amp;rsquo;t that a thing women say? Do guys say that? And then, this thought hit me, in the way that thoughts are known to hit people.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I cannot wear pants from Banana Republic. AND I AM FINE WITH THAT!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I have spent a long time &amp;ndash; ever since I started this weight loss journey &amp;ndash; thinking that 175# was this ideal weight for me. According to my height and BMI calculation, 175# is my perfect target. But maybe that&amp;rsquo;s not me. I kept thinking I should be 175# with 15% body fat.&lt;/p&gt;

&lt;p&gt;So why is CrossFit relevant to this story?&lt;/p&gt;

&lt;p&gt;I weigh, plus or minus 3 pounds, the same as I did in November: 199#. I am working out 5-6 days per week, with some decent weight training on four of those days. My push-ups suck, but they&amp;rsquo;re getting better. My cleans suck, but I think that&amp;rsquo;s because my form is terrible. I can kill box jumps and squats. Ten weeks ago, my one rep max on standing overhead press was 75#. This week, my max is 100#, and I lifted 75# 13 times in a single set. Progress!&lt;/p&gt;

&lt;p&gt;I have dropped 2.5&amp;#8221; off my waist, but I can&amp;rsquo;t buy smaller pants because my thighs have gotten bigger. (Thus, the reason I am shopping for a new belt.) &lt;strong&gt;And I&amp;rsquo;m perfectly fine with that.&lt;/strong&gt; A large shirt has gone from being tight in the belly to just about perfect.&lt;/p&gt;

&lt;p&gt;Maybe I&amp;rsquo;m supposed to be closer to 200#, but with a bodyweight bench press and a 315# squat.&lt;/p&gt;

&lt;p&gt;And I don&amp;rsquo;t need to be some bulked-up monster, either. Just fitter and faster.&lt;/p&gt;

&lt;p&gt;I am still not happy with the way I look. My body fat, based on pictures, is still probably close to 20-22%. But it&amp;rsquo;s much better than the 25-27% it was a few months ago. And I will drop weight &amp;ndash; probably my usual 10# &amp;ndash; this summer once I&amp;rsquo;m running and cycling outdoors more frequently. But I&amp;rsquo;m not going to look. I have quit using my scale. I&amp;rsquo;m going on three weeks without looking. I will just keep doing stuff and pushing myself hard. The mirror, my clothes, and my performance tell me 1000 times more than that one number on that damned device.&lt;/p&gt;

&lt;p&gt;That&amp;rsquo;s just me, I suppose, and guys are probably just as fucked up as girls when it comes to body acceptance. But I do feel better about myself &amp;mdash; a little bit every day.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/I0csplglEVI" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/02/10/body-acceptance/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[I Want Conditional Assignment In All The Languages]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/enmkv_CdvNY/" />
    <updated>2013-02-08T08:20:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/02/08/i-want-conditional-assignment-in-all-the-languages</id>
    <content type="html">&lt;p&gt;I get that not every language can have every feature. But there are some language features that just seem obvious to me. Conditional assignment is one of those features.&lt;/p&gt;

&lt;h2&gt;What Is Conditional Assignment?&lt;/h2&gt;

&lt;p&gt;Not every language has this feature. The super short answer is that it is an assignment that happens conditionally. Specifically, it prevents assignment from happening twice. In these examples, suppose we want to ensure we have defined an array. I&amp;rsquo;ll use integers, but it really doesn&amp;rsquo;t matter what you&amp;rsquo;re putting in the object.&lt;/p&gt;

&lt;p&gt;In C#, you would do conditional assignment one of these two ways.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;csharp_example.cs &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='csharp'&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;// Using the ternary operator&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="p"&gt;!=&lt;/span&gt; &lt;span class="k"&gt;null&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;// Using the null coalesce operator&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;In JavaScript, you can use the or &lt;code&gt;||&lt;/code&gt; operator to accomplish the same thing. This works in JS because the || operator returns a value, not a boolean.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;javascript_example.js &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;array&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[]);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;h3&gt;Examples of Conditional Operators&lt;/h3&gt;

&lt;p&gt;Having conditional assignment takes care of null checks for you. It&amp;rsquo;s one of those things that makes a language simple on the eyes, and it cuts down on character noise. Here&amp;rsquo;s what it would look like in CoffeeScript.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;coffeescript_example.coffee &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='coffeescript'&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# Using ternary&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;array = &lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nv"&gt;array : &lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# Using unless&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;array = &lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="nx"&gt;unless&lt;/span&gt; &lt;span class="nx"&gt;array&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# Using JavaScript, because JS still works in CS&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;array = &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;array&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# Using conditional assignment!&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;array&lt;/span&gt; &lt;span class="o"&gt;?=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;In Ruby, conditional assignment looks like this.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;ruby_example.rb &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="o"&gt;||=&lt;/span&gt; &lt;span class="o"&gt;[]&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;I don&amp;rsquo;t see any reason we couldn&amp;rsquo;t add this feature to C#. We have assignment. We have null checks. Create a new operator for the language!&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;enhanced_csharp_example.cs &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='csharp'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;array&lt;/span&gt; &lt;span class="p"&gt;??=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;I want this feature in every language. Language designers, go make that happen!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/enmkv_CdvNY" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/02/08/i-want-conditional-assignment-in-all-the-languages/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Getting to Global Variables in CoffeeScript]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/n0BBFLsTVTM/" />
    <updated>2013-02-07T06:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/02/07/getting-to-global-variables-in-coffeescript</id>
    <content type="html">&lt;p&gt;I&amp;rsquo;m trying something in &lt;a href=""&gt;CoffeeScript&lt;/a&gt; this morning. Right off the bat, I need to be able to access the global &lt;code&gt;window&lt;/code&gt; object. CoffeeScript really likes to keep it&amp;rsquo;s area nice and tidy. It does everything in its power to keep you out of the global namespace. That&amp;rsquo;s fine, right up until you need to get to the global namespace.&lt;/p&gt;

&lt;p&gt;The answer is to add a line like this to your code.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='coffeescript'&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;root = &lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Instead of accessing the &lt;code&gt;window&lt;/code&gt; global, you will use &lt;code&gt;root&lt;/code&gt; instead. This only makes sense when you consider that CoffeeScript is designed to be an anywhere-JavaScript framework. With tools like &lt;a href="http://nodejs.org"&gt;Node&lt;/a&gt;, JavaScript isn&amp;rsquo;t just for the browser any longer.&lt;/p&gt;

&lt;h3&gt;Solution&lt;/h3&gt;

&lt;p&gt;Here&amp;rsquo;s the code you need. You&amp;rsquo;ll need the line from above. &lt;strong&gt;And&lt;/strong&gt;, you must explicitly add whatever you&amp;rsquo;re adding to the &lt;code&gt;root&lt;/code&gt; object. If you do not do this, your code will be wrapped in a closure and inaccessible from your local code.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='coffeescript'&gt;&lt;span class='line'&gt;&lt;span class="nv"&gt;root = &lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Tester&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nv"&gt;sayHello: &lt;/span&gt;&lt;span class="nf"&gt;(target) -&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;alert&lt;/span&gt; &lt;span class="s"&gt;&amp;quot;Hello, &lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nx"&gt;unless&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tester&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nv"&gt;root.tester = &lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Tester&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Here&amp;rsquo;s the result when compiled into JS. Verbose, isn&amp;rsquo;t it? &lt;em&gt;Why 6 lines of CoffeeScript becomes 14 lines of JavaScript is beyond me.&lt;/em&gt; If I&amp;rsquo;m writing my own JavaScript classes, I typically won&amp;rsquo;t use prototyping. Not that there&amp;rsquo;s anything wrong with that. It&amp;rsquo;s just not how I would do the same thing.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;span class='line-number'&gt;16&lt;/span&gt;
&lt;span class='line-number'&gt;17&lt;/span&gt;
&lt;span class='line-number'&gt;18&lt;/span&gt;
&lt;span class='line-number'&gt;19&lt;/span&gt;
&lt;span class='line-number'&gt;20&lt;/span&gt;
&lt;span class='line-number'&gt;21&lt;/span&gt;
&lt;span class='line-number'&gt;22&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='javascript'&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;Tester&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nx"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;undefined&amp;quot;&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nx"&gt;Tester&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;Tester&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;Tester&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;prototype&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sayHello&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;target&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;Hello, &amp;quot;&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;target&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;!&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="p"&gt;};&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;Tester&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;})();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tester&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nx"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tester&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Tester&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Now you can see why using &lt;code&gt;root&lt;/code&gt; works. When this is run in your browser, the &lt;code&gt;.call(this)&lt;/code&gt; is passing &lt;code&gt;window&lt;/code&gt; as the root object. Still, it all works as expect. I open this up in my browser, and all works exactly as expected.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://jarrettmeyer.com/images/content/2013/02-feb/coffeescript_hello_world_tester.png" title="CoffeeScript Hello World Test" &gt;&lt;/p&gt;

&lt;p&gt;Hope this helps. Thanks to this &lt;a href="http://stackoverflow.com/questions/6347671/coffeescript-coffee-w-name-of-file-coffee-complains-window-is-not-defined"&gt;question and answer from StackOverflow&lt;/a&gt; for pointing me in the right direction.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/n0BBFLsTVTM" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/02/07/getting-to-global-variables-in-coffeescript/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[I Will Rise & Heavenly Dance]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/nB4p7556uvU/" />
    <updated>2013-02-05T06:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/02/05/i-will-rise</id>
    <content type="html">&lt;p&gt;So, I&amp;rsquo;m pretty used to putting myself out there. I put photos of myself on Facebook. I &lt;em&gt;obviously&lt;/em&gt; have no problem with writing public on just about any topic. I play piano in front of people every week. But I&amp;rsquo;ve never recorded myself solo.&lt;/p&gt;

&lt;p&gt;Until now. Here are two songs that I&amp;rsquo;ve played for St. Christopher&amp;rsquo;s choir.&lt;/p&gt;

&lt;iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F77777188&amp;amp;auto_play=false&amp;amp;show_artwork=true&amp;amp;color=5f9fd7"&gt;&lt;/iframe&gt;




&lt;iframe width="100%" height="166" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F77777076&amp;amp;auto_play=false&amp;amp;show_artwork=true&amp;amp;color=5f9fd7"&gt;&lt;/iframe&gt;


&lt;p&gt;Neither of these songs are, by any stretch of the imagination, perfect. There are missed and omitted notes. There are passages that I have simplified. The tempos aren&amp;rsquo;t quite perfect. Whatever. This is me, and this is something I love to do.&lt;/p&gt;

&lt;p&gt;I am amazed by anyone who will post video of themselves &lt;a href="http://www.youtube.com/watch?v=TF6cnLnEARo"&gt;playing any instrument on YouTube&lt;/a&gt;. The amount of musical talent in this world is incredible.&lt;/p&gt;

&lt;p&gt;So there. It&amp;rsquo;s out now. I hope to do this more often. Now, back to practice.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/nB4p7556uvU" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/02/05/i-will-rise/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Fashion Is A Form Of Expression]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/hr7NkAQcrCU/" />
    <updated>2013-02-04T06:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/02/04/fashion-is-a-form-of-expression</id>
    <content type="html">&lt;blockquote&gt;&lt;p&gt;Fashion is one of the very few forms of expression in which women have more freedom than men.&lt;/p&gt;&lt;p&gt;And I don’t think it’s an accident that it’s typically seen as shallow, trivial, and vain.&lt;/p&gt;&lt;p&gt;It is the height of irony that women are valued for our looks, encouraged to make ourselves beautiful and ornamental… and are then derided as shallow and vain for doing so. And it’s a subtle but definite form of sexism to take one of the few forms of expression where women have more freedom, and treat it as a form of expression that’s inherently superficial and trivial. Like it or not, fashion and style are primarily a women’s art form. And I think it gets treated as trivial because women get treated as trivial.&lt;/p&gt;&lt;footer&gt;&lt;strong&gt;Greta Christina&lt;/strong&gt; &lt;cite&gt;Fashion Is a Feminist Issue&lt;/cite&gt;&lt;/footer&gt;&lt;/blockquote&gt;


&lt;p&gt;Via &lt;a href="http://freethoughtblogs.com/greta/2011/09/02/fashion-is-a-feminist-issue/"&gt;FreethoughtBlogs.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I really don&amp;rsquo;t want to go too deeply into this. First, I am a man that shapes the world I see differently. Second, without my bride, I would probably have no fashion-sense at all. If I look good, Meaghan gets the credit. If I don&amp;rsquo;t, then it&amp;rsquo;s my fault.&lt;/p&gt;

&lt;p&gt;The article, originally from September 2011, is quite a good read. You should check out the rest of it.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/hr7NkAQcrCU" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/02/04/fashion-is-a-form-of-expression/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Mocking an HTTP Response in RSpec]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/c2nUPxK7I_o/" />
    <updated>2013-01-31T09:10:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/01/31/mocking-an-http-response-in-rspec</id>
    <content type="html">&lt;p&gt;One of the great parts about the Ruby language is that all classes and open and active at all times. That means that testing is incredibly easy because you can overwrite any class at any time for the purposes of a test.&lt;/p&gt;

&lt;p&gt;Let&amp;rsquo;s get right down to it. Here&amp;rsquo;s the production code&amp;hellip;&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;widget_content&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;elsif&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content_source&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;uri&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Uri&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;content_source&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Net&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_response&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;uri&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;else&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;I keep reflecting on the .NET world, probably because I have so much experience in that environment. The above method, as written, is untestable in .NET because of the static method &lt;code&gt;get_response&lt;/code&gt;. &lt;em&gt;Attn Rubyists: .NET &amp;ldquo;static&amp;rdquo; is mostly the same as a Ruby class method.&lt;/em&gt; You would have to create an adapter interface for the HTTP operation and create a concrete implementation of that interface. You would then inject the adapter interface, either into the method as a parameter or the class itself. Or you would need to use a &lt;a href="http://en.wikipedia.org/wiki/Service_locator_pattern"&gt;Service Locator&lt;/a&gt; to retrieve the adapter. Although there are plenty of developers who will tell you that &lt;a href="http://blog.ploeh.dk/2010/02/03/ServiceLocatorIsAnAntiPattern.aspx"&gt;Service Location is an anti-pattern&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Anyway, on with the show. Here&amp;rsquo;s the Ruby test.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FakeResponse&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;body&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="s2"&gt;&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;h1&amp;gt;Hello, World!&amp;lt;/h1&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;fetches widgets content from content source when content source is given&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="no"&gt;Net&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;HTTP&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;stub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:get_response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;and_return&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;FakeResponse&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;DashboardWidget&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="ss"&gt;:content_source&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;http://www.example.com&amp;quot;&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;widget_content&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="kp"&gt;include&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;&amp;quot;&amp;lt;html&amp;gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;My fake lives inside by test spec. I don&amp;rsquo;t have any unnecessary adapters or implementations in my production code. This makes production code much more obvious to the reader.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/c2nUPxK7I_o" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/01/31/mocking-an-http-response-in-rspec/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[My Brain Has Checked Out]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/Ouo56YyUBYk/" />
    <updated>2013-01-17T08:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/01/17/my-brain-has-checked-out</id>
    <content type="html">&lt;p&gt;&lt;a href="http://tomtunguz.com/"&gt;Tomasz Tunguz&lt;/a&gt; authored a post on &lt;a href="http://tomtunguz.com/why-to-do-lists-are-failing-us"&gt;Why To-Do Lists Are Failing Us&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Task management tools fail users because they operate without context. How many times have you been to the grocery store and forgotten the dill pickles you were asked to buy? Or met someone and tens [sic] minutes later realized you forgot to ask an important question?&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;Yeah, sure. That &lt;em&gt;might be&lt;/em&gt; a problem. I have several task lists just for this reason. There&amp;rsquo;s a home list, a grocery list, a general work list, and a list for each client. This method works for me, but it does mean that I have a list of lists. You take the good, you take the bad, and all that. I write and consult on software for a living. I pre-wired for this type of list-making activity. I am accustomed to ticketing systems that tell me what the top priorities are, and I&amp;rsquo;m used to breaking down my work into lots of little pieces. I win at lists.&lt;/p&gt;

&lt;p&gt;Tomasz is definitely correct about thing: &lt;strong&gt;there&amp;rsquo;s no shortage of to-do apps in the App Store and Google Play&lt;/strong&gt;. If you own an iPhone, do we really need this many apps when the phone already has Reminders installed as a default application as part of the operation system.&lt;/p&gt;

&lt;p&gt;Maybe &amp;mdash; &lt;em&gt;because I see it in myself&lt;/em&gt; &amp;mdash; we are blaming the application when we don&amp;rsquo;t get stuff done. Are there flaws? Sure. In my opinion, these flaws are easily overcome, though. There&amp;rsquo;s a bigger problem, though: &lt;em&gt;my list is filled with shit I just don&amp;rsquo;t care about&lt;/em&gt;. That stuff, for whatever reason, tends to not get done. When I&amp;rsquo;m working on an awesome project, then no list is necessary. And it&amp;rsquo;s way too easy to not get stuff done these days: Facebook, Twitter, Pinterest, Manteresting, YouTube. Modern connectivity can make it so you have access to work stuff every waking hour of every damn day. Pick your thing. There is plenty of time filler on the wires.&lt;/p&gt;

&lt;p&gt;Maybe, it&amp;rsquo;s not the app. Maybe, it&amp;rsquo;s the rest of the clutter.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/Ouo56YyUBYk" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/01/17/my-brain-has-checked-out/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Should I Validate On The Client Or On The Server]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/yYcA7mgcCq0/" />
    <updated>2013-01-14T06:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/01/14/should-i-validate-on-the-client-or-on-the-server</id>
    <content type="html">&lt;p&gt;When doing web development, this is a pretty common question. It shows up quite a bit on &lt;a href="http://stackoverflow.com"&gt;stackoverflow&lt;/a&gt;, even when moderators try to do a good job of removing duplicate questions.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;Should I validate on the client (JavaScript) or on the server (C#, Ruby, etc.)?&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;Yes, writing validation code can be annoying. More annoying? Doing it twice in two different langauges in two different parts of your application. (e.g. C# or Ruby is used on the server and JavaScript on the UI.) Yes, there are tools that help with this. See how Microsoft&amp;rsquo;s &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.dataannotations.schema.aspx"&gt;Data Annotations library&lt;/a&gt; is integrated in &lt;a href="http://www.asp.net/mvc"&gt;ASP.NET MVC&lt;/a&gt;, for example.&lt;/p&gt;

&lt;h3&gt;Repeat After Me&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you care about your &lt;strong&gt;data&lt;/strong&gt;, you will validate on the &lt;strong&gt;server&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;If you care about your &lt;strong&gt;user experience&lt;/strong&gt;, you will validate on the &lt;strong&gt;client&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;These two questions are mutually exclusive. You can make one decision indepently from the other. In my experience, for every application I&amp;rsquo;ve worked on in the past five years, I&amp;rsquo;ve done both client-side and server-side validation. We do both, because we care about both situations.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/yYcA7mgcCq0" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/01/14/should-i-validate-on-the-client-or-on-the-server/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Not All Ruby Code Is Beautiful]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/cor5XrEYGfs/" />
    <updated>2013-01-11T06:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/01/11/not-all-ruby-code-is-beautiful</id>
    <content type="html">&lt;p&gt;If it wasn&amp;rsquo;t already quite obvious, I really like Ruby. Specifically, I like how much more I can do with much less typing and effort on my part. Sure, compared to C#, I lose compile-time type checking. But I gain quite a bit from the effort-to-output ratio.&lt;/p&gt;

&lt;p&gt;From the &lt;em&gt;I Can Write Bad In Any Language&lt;/em&gt; department, I found this in my codebase this week.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;% unless &lt;/span&gt;&lt;span class="n"&gt;has_custom_partial?&lt;/span&gt; &lt;span class="sx"&gt;%&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="sx"&gt;  &amp;lt;%= render(:partial =&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;document_list&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="sx"&gt;%&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="sx"&gt;&amp;lt;% else %&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sx"&gt;%= render(:partial =&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;&amp;#39;document_list&amp;#39;&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="sx"&gt;%&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="sx"&gt;&amp;lt;% end %&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;For future reference&amp;hellip;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Yes, there is a very detailed &lt;a href="https://github.com/styleguide/ruby"&gt;Ruby Styleguide published by Github&lt;/a&gt;. No, it is not necessarily &amp;ldquo;official&amp;rdquo;, but it certainly should be.&lt;/li&gt;
&lt;li&gt;We &lt;strong&gt;never&lt;/strong&gt; use the &lt;code&gt;unless&lt;/code&gt; keyword with an &lt;code&gt;else&lt;/code&gt; block. Never, never, never. Yes, it works. that doesn&amp;rsquo;t mean you have permission to do it. If you find yourself needing the &lt;code&gt;else&lt;/code&gt; condition, then invert the conditional clause.&lt;/li&gt;
&lt;li&gt;There&amp;rsquo;s not even a point to this block anyway. WTF?&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;Please, do not let ugly code live. Nuke it from orbit. It&amp;rsquo;s the only way to be sure.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/cor5XrEYGfs" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/01/11/not-all-ruby-code-is-beautiful/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Logging Is Not A Business Concern]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/t43w4vlYV7g/" />
    <updated>2013-01-10T06:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/01/10/logging-is-not-a-business-concern</id>
    <content type="html">&lt;p&gt;While meeting with a fellow developer, I was asked about I handle &lt;a href="http://en.wikipedia.org/wiki/Dependency_injection"&gt;dependency injection&lt;/a&gt; for loggers into my classes. My response, rather quickly was, &amp;ldquo;I never inject my loggers.&amp;rdquo; This, of course, leads to the obvious question, &amp;ldquo;How do you test that logs are written?&amp;rdquo; Again, my answer is simple: I don&amp;rsquo;t test logging.&lt;/p&gt;

&lt;p&gt;I don&amp;rsquo;t test my logging, because &lt;strong&gt;logging is not a business concern&lt;/strong&gt;. This is how I do logging in every application I have ever written.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='csharp'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="n"&gt;ILog&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;LogManager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;GetLogger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;typeof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyClass&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;DoSomething&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;In method DoSomething. input = {0}&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Yes, just a plain old log4net logger with a plain old initializer. No injection. Nothing fancy. It is &lt;code&gt;static&lt;/code&gt; and &lt;code&gt;readonly&lt;/code&gt; to prevent creating a bunch of new objects every time.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve come about this by realizing what logging is and what logging is not. Logging is informational data collection for &lt;strong&gt;your&lt;/strong&gt; business, not your client&amp;rsquo;s business. Specifically, it is important to me, the developer. It helps me, the developer, diagnose issues and make decisions. It is a diagnostic tool. &lt;em&gt;What pages are used the most heavily? How are they used? Who is using the application the most? What roles do those high-use users have? Where are they coming from? How long does it take pages to load? What are the most frequently used queries? What buttons are being clicked? And in what order? What errors is the user seeing?&lt;/em&gt; These are all questions that are important to me and my bosses.&lt;/p&gt;

&lt;p&gt;If you, as the developer, care that user &lt;em&gt;jdoe&lt;/em&gt; logged on at &lt;em&gt;2:37pm&lt;/em&gt; from IP address &lt;em&gt;1.2.3.4&lt;/em&gt; and the password attempt was either a &lt;em&gt;success&lt;/em&gt; or a &lt;em&gt;failure&lt;/em&gt;, then that would be a great thing to throw into a log. If, on the other hand, you have a business requirement that you must show a sign on history of users for security audit purposes, then that information should be stored in a &lt;code&gt;Signon_History&lt;/code&gt; table.&lt;/p&gt;

&lt;p&gt;When I have complete control over such things, I don&amp;rsquo;t even keep my logs in the same database catalog as the rest of the application. I don&amp;rsquo;t have an offsite backup plan for my logs. And I have automated SQL jobs that occasionally purge data based on log type. e.g. Debug logs are purged weekly; warning logs are purged monthly; etc.&lt;/p&gt;

&lt;p&gt;When it comes to production debug logging, I try to avoid it as much as I can. From the outside observer, you are debugging in a production environment. That should already scream to you: this is not ideal! Sometimes, yes, it is unavoidable. There are problems that can happen in a production environment that may never happen in development or testing scenarios. Production debugging should be the exception, rather than the rule. I look at this type of logging as a failure to write testable code.&lt;/p&gt;

&lt;p&gt;In the above example, suppose we are having an issue with &lt;code&gt;input&lt;/code&gt;. Perhaps the &lt;code&gt;DoSomething&lt;/code&gt; method behaves differently based on the value of &lt;code&gt;input&lt;/code&gt;. It is far more beneficial to expose &lt;code&gt;Inputs&lt;/code&gt; as a property and write unit tests that check the values of &lt;code&gt;Inputs&lt;/code&gt; as the method is called. These unit tests are now repeatable, and will be tested every time there is a checkin to your source control.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='csharp'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;();&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;IEnumerable&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Inputs&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;get&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;DoSomething&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;inputs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;input&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="c1"&gt;// Continue with the rest of the method.&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;A unit test is always preferable to logging. Yes, you might need to log at first, if only to figure out what the user is doing. Once you learn it, refactor the code to test for such a condition. Make sure it doesn&amp;rsquo;t happen again.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/t43w4vlYV7g" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/01/10/logging-is-not-a-business-concern/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[There Is Another Way]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/fQdEt5tIS9o/" />
    <updated>2013-01-09T06:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/01/09/there-is-another-way</id>
    <content type="html">&lt;p&gt;Cap Watkins posted that &lt;a href="http://blog.capwatkins.com/quitting-linkedin"&gt;he was quitting LinkedIn&lt;/a&gt;. That&amp;rsquo;s good. We all need less crap in our lives. He quit because of the flurry of messages from recruiters and the amount of crap spam that goes into your inbox.&lt;/p&gt;

&lt;blockquote&gt;&lt;p&gt;I guess that’s what it takes to take a company public and to keep it profitable. It’s just sad the things we do to our lovely, useful products in order to take them to the next level. There must be another way.&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;Fret not! There is another way.&lt;/p&gt;

&lt;p&gt;It&amp;rsquo;s something I like to call: &lt;strong&gt;Charge For Your Product&lt;/strong&gt;. I know. Fancy, isn&amp;rsquo;t it.&lt;/p&gt;

&lt;p&gt;Nothing in this world is free, despite what we have gotten used to with the Facebooks, Google Mails, and Instagrams of the world. Maybe something starts out small &amp;mdash; two or three developers, working in their spare time while they hold down &amp;ldquo;real&amp;rdquo; jobs. But then you need a real sysadmin to make sure the servers stay up. And then you need a real DBA to help you with some query optimization and indexes. And then you would like someone with high-quality UX skills to pretty-up the UI. And those are paid positions. Paying people requires cash. So you need to monetize your product. Have you even thought about a payment structure?&lt;/p&gt;

&lt;p&gt;I don&amp;rsquo;t know if you&amp;rsquo;re aware of this, but the digital world is getting cheaper every year. Cloud platforms make hosting your solutions quite easy, managable, and financially feasible. I promise you, you can be very happy with a modest user base and $19/year for a subscription style service. Will you be driving Ferraris and dating super-models? Probably not, but you don&amp;rsquo;t really want that lifestyle anyway.&lt;/p&gt;

&lt;p&gt;Quit trying to be the next Facebook. We&amp;rsquo;ve already got a Facebook. Everyone&amp;rsquo;s on it, and Facebook has their own financial problems. Will you get huge? No. But you don&amp;rsquo;t need to be huge. More importantly, you don&amp;rsquo;t &lt;strong&gt;want&lt;/strong&gt; to be huge. Huge means a whole litany of problems that you don&amp;rsquo;t want to deal with. Huge means having an HR department and dress code policies and strict vacation rules. Huge means your infrastructure is a pain to work with and meetings and Microsoft Outlook. Huge means lawyers.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve done huge. I hated it. It&amp;rsquo;s shit work with even shittier developers.&lt;/p&gt;

&lt;p&gt;Build something that you&amp;rsquo;re passionate about. Build something that excites you. And then charge a reasonable amount for the service you provide. If you can&amp;rsquo;t do that, then you don&amp;rsquo;t have a business opportunity, you have a hobby.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/fQdEt5tIS9o" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/01/09/there-is-another-way/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Your Fast Feedback Isn't Fast Enough]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/eMlzX6UdKGQ/" />
    <updated>2013-01-08T11:55:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2013/01/08/your-fast-feedback-isnt-fast-enough</id>
    <content type="html">&lt;p&gt;&lt;img class="left" src="http://jarrettmeyer.com/images/content/2012/12-dec/dressage-horse.jpeg" width="220" height="207"&gt;&lt;/p&gt;

&lt;p&gt;My wife rides horses, specifically a style known as &lt;a href="http://en.wikipedia.org/wiki/Dressage"&gt;dressage&lt;/a&gt;. Dressage is a style of riding designed to push a horse to its physical limits of athleticism and movement. The types of techniques performed are incredibly technical; the placement of the horse&amp;rsquo;s head, back, and feet very precise. Watching a 1500 pound animal perform ballet is impressive indeed.&lt;/p&gt;

&lt;p&gt;The most impressive aspect of dressage? When done well, you cannot tell that the rider is doing anything at all.&lt;/p&gt;

&lt;p&gt;Horses are incredibly sensitive creatures. They are capable of reacting to slight changes in pressure that many humans wouldn&amp;rsquo;t even notice. The best riders spent thousands of hours training, usually riding multiple horses per week. They learn about the minuscule changes they have to make with their hands, arms, body, seat, and legs to exactly the movement they want out of the animal. Exactly how much change &amp;ndash; and no more.&lt;/p&gt;

&lt;p&gt;Horses bring their own minds into the arena, too. Some of the horses I&amp;rsquo;ve met are quite intelligent. Horses will spook at a shadow they&amp;rsquo;ve seen dozens of times or a tractor that backfires a quarter mile away on the next farm. Again, good riders seem to know this. They pick up cues from the horse, and they react. Because they are so well trained, they can react sooner, and with very little perceived effort, making a tiny correction to put the horse back on track.&lt;/p&gt;

&lt;p&gt;Put succinctly, dressage equestrians are &lt;strong&gt;Agile&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A fast feedback cycle is the heart of agile. We write unit tests, because automated testing is always faster than manual testing. We use build and integration servers because we are merging code written by multiple developers. When that code is merged, dependencies must be checked. We write behavior driven tests that ensure the application still performs in expected fashions. We have development servers that will publish the site and run our JavaScript tests for us. We use &lt;a href="https://github.com/"&gt;modern source control&lt;/a&gt; systems that allow for dozens, if not hundreds, of &lt;a href="http://en.wikipedia.org/wiki/Atomic_commit#Revision_Control"&gt;atomic commits&lt;/a&gt; each day.&lt;/p&gt;

&lt;p&gt;I have reached a point in my career where these tools are not optional. These are my tools. When they are gone, I might as well be missing a hand or an eye. In fact, they are so integral in how I work, that I refuse to work without them. And if I go to a client who does not have them, I will even offer to set them up for the client. And if it still doesn&amp;rsquo;t happen, then I won&amp;rsquo;t be working for that client very long.&lt;/p&gt;

&lt;p&gt;No matter how fast your feedback cycle is, I promise you it isn&amp;rsquo;t fast enough. Your unit tests need to be run every time code is merged. &lt;strong&gt;Every time.&lt;/strong&gt; &lt;em&gt;This point is not up for debate.&lt;/em&gt; What are the most critical tests? Run those first. What are the slowest tests? Run those in batches. Are your most critical tests also the slowest? I can guarantee that you are mingling business concerns with infrastructure. Abstract away those two pieces from each other.&lt;/p&gt;

&lt;p&gt;Do you test your client-side JavaScript? You should, because &lt;strong&gt;JavaScript is code, too&lt;/strong&gt;. Once your integration server builds your project and runs your server-side tests, code should automatically be deployed to a testing server. Your automation should invoke your &lt;a href="http://qunitjs.com"&gt;QUnit&lt;/a&gt; or &lt;a href="http://pivotal.github.com/jasmine/"&gt;Jasmine&lt;/a&gt; test suite and report back on failures.&lt;/p&gt;

&lt;p&gt;If you are waiting on a human, &lt;em&gt;for specs, testing, or anything,&lt;/em&gt; quit it. Right now. You are wasting your time, killing your productivity, and hemorrhaging your company&amp;rsquo;s resources. If you need a tester, then get one on the spot, sitting next to the developer, and figure out an automation that works for the necessary conditions. We are software developers. &lt;strong&gt;Our entirety of work is remove mundane or difficult manual processes.&lt;/strong&gt; Do not exacerbate the problem by creating your own manual work.&lt;/p&gt;

&lt;p&gt;If a request does in fact takes that long, then you don&amp;rsquo;t have the right people working on the problem, you are not effective at sharing information, or you haven&amp;rsquo;t broken the problem down into small enough actionable units. In most cases, it is some combination of all three. You should be able to see noticeable progress daily. Yes. Daily.&lt;/p&gt;

&lt;p&gt;How do users &lt;a href="http://newrelic.com"&gt;use your application&lt;/a&gt;? Yes, I know you wrote the application to be used a certain way. But humans are ingenious creatures that do strange things. If an error does make it to production, how quickly do your developers &lt;a href="http://www.exceptional.io"&gt;know about it&lt;/a&gt;? How quickly can you fix the problem or make adjustments? Can you change a page slowly over time in a way that coerces the user to work in an expected and manageable workflow? Major site redesigns almost always lead to lots of customer support calls.&lt;/p&gt;

&lt;p&gt;Think you&amp;rsquo;re fast? Think again. We all want to build something amazing, and amazing is incredibly critical of itself.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This article was originally published on &lt;a href="http://blog.fusionalliance.com/blog/caffeine-in-code-out/your-fast-feedback-isnt-nearly-fast-enough"&gt;Fusion Alliance&amp;rsquo;s Corporate Blog&lt;/a&gt; on 3 January 2013.&lt;/em&gt;&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/eMlzX6UdKGQ" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2013/01/08/your-fast-feedback-isnt-fast-enough/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Eating Eggs, Lifting Weights, and Pushing Pedals]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/jlluJGHk94E/" />
    <updated>2012-12-29T06:57:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2012/12/29/eating-eggs-lifting-weights-and-pushing-pedals</id>
    <content type="html">&lt;p&gt;My wife, Meaghan, and I are fairly health-conscious people. She&amp;rsquo;s completed two 140.6 Ironman races. I&amp;rsquo;ve been in a few triathlons myself. Neither of us are a stranger to the gym or working out.&lt;/p&gt;

&lt;h2&gt;Update On CrossFit&lt;/h2&gt;

&lt;p&gt;I&amp;rsquo;ve been &lt;a href="http://jarrettmeyer.com/blog/2012/11/20/a-week-of-crossfit/"&gt;doing CrossFit&lt;/a&gt; for five weeks now. It&amp;rsquo;s awesome. I wouldn&amp;rsquo;t say I&amp;rsquo;m good at it, but I don&amp;rsquo;t suck at it, either. I still need assistance from the bands when doing pull-ups, but I&amp;rsquo;m getting better. And I&amp;rsquo;ve got muscles; I can actually see a little bit of back definition after such a short time. I really like the high-intensity cardio &amp;ndash; running, rowing, box jumps, air squats &amp;ndash; because they highlight more of my good points. It messes with your head when someone, male or female, appears to be 1/3 smaller than you and can press 50# more.&lt;/p&gt;

&lt;p&gt;Here&amp;rsquo;s an idea of what I&amp;rsquo;ve done so far&amp;hellip;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Pull-ups are now done with elastic bands. I don&amp;rsquo;t have to jump from the ground. On my very first night, I couldn&amp;rsquo;t even do a pull-up with bands.&lt;/li&gt;
&lt;li&gt;Back squat max is 205#.&lt;/li&gt;
&lt;li&gt;Overhead press max is 85#.&lt;/li&gt;
&lt;li&gt;Overhead squat max is 55#. I&amp;rsquo;m certain I can do more, but this was part of a workout.&lt;/li&gt;
&lt;li&gt;The most I&amp;rsquo;ve deadlifted so far is 155#. I&amp;rsquo;m certain I can do more. This was part of a workout.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;There are lots of max lifts that we haven&amp;rsquo;t figured out yet. I&amp;rsquo;m not sure what my front squat one-rep max is. I&amp;rsquo;ve done them a few times, but I didn&amp;rsquo;t write down my weight. I&amp;rsquo;ve learned how to hang clean and power hang clean the bar, but not for any substantial weight as of yet.&lt;/p&gt;

&lt;h2&gt;Spinning&lt;/h2&gt;

&lt;p&gt;I&amp;rsquo;m also starting up the spinning again. I&amp;rsquo;m attending my second Compu-Trainer later today. So that&amp;rsquo;s fun. It gives me a chance to do a long-effort, much different from the short-duration, high-intensity CrossFit workouts.&lt;/p&gt;

&lt;p&gt;If you like cycling and ever get a chance to try out a Compu-Trainer, I highly suggest you try one out. They&amp;rsquo;re much more fun that spinning or a normal indoor trainer. Plus, since you bring your own ride, you know it&amp;rsquo;s going to be comfortable.&lt;/p&gt;

&lt;h2&gt;Eating Eggs&lt;/h2&gt;

&lt;p&gt;I know I have let my nutrition slide. A lot. Long, long ago, in May 2005, I maxed out at 251#. At my lowest, October 2008, I weighed 178#. I was running a ton, and I was watching every single calorie I put in my body. It was a lot of work &amp;ndash; both the calories in and calories out. But it was the food (or lack of) that made the difference in total body weight.&lt;/p&gt;

&lt;p&gt;This year, 2012, I worked out a lot. No seriously. A. Lot. But I didn&amp;rsquo;t monitor my food intake. I ate what I wanted, when I wanted it. And that included a lot of sweets and junk. By the time my Half Ironman came around in July, I was back down to 190#, knocking on the door of being back in the 180s, but it never happened. I don&amp;rsquo;t keep a food journal any longer. But it&amp;rsquo;s probably something I should be doing, especially since &lt;a href="http://www.myfitnesspal.com/"&gt;so many sites&lt;/a&gt; make it so damn easy.&lt;/p&gt;

&lt;p&gt;The last two weeks, I have held steady at 199#. Sure, I was hoping to lose weight given the amount of working out I&amp;rsquo;ve done. In reality, I&amp;rsquo;ve eaten brownies, nuts, Chex Mix, sat down for big dinners, and I&amp;rsquo;ve lots count of how many cookies have gone down my mouth. Honestly, break even was probably the best possible outcome in the past three weeks. And, I&amp;rsquo;ve got that previously mentioned new-found muscle definition. I know I&amp;rsquo;ve added muscle. Mathematically, if my weight has remained the same and I&amp;rsquo;ve added muscle, then I must have lost some fat in the last five weeks.&lt;/p&gt;

&lt;p&gt;A few weeks ago, Meaghan and I decided to get rid of the &amp;ldquo;over-processed&amp;rdquo; foods in our house. That included boxed cereals. So long Cinnamon Toast Crunch, Lucky Charms, and Reese&amp;rsquo;s Puffs. Of course, that means that I needed to find a new source of morning nourishment.&lt;/p&gt;

&lt;p&gt;Which leads to eggs. There&amp;rsquo;s a lot on the internet about eggs. Here&amp;rsquo;s what I was able to find.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;One large egg has about 70 calories, 6g protein, and 5g fat. But it&amp;rsquo;s all the good fats that you&amp;rsquo;re supposed to be eating.&lt;/li&gt;
&lt;li&gt;One large egg has about 210mg cholesterol.&lt;/li&gt;
&lt;li&gt;There is no confirmed scientific link between dietary cholesterol and blood cholesterol.&lt;/li&gt;
&lt;li&gt;A lot of people on the internet don&amp;rsquo;t know that last one.&lt;/li&gt;
&lt;li&gt;One large egg white is only about 16 calories and 3.5g protein. There is no fat or cholesterol in egg whites.&lt;/li&gt;
&lt;li&gt;Along with no fat and no cholesterol, there are no nutrients in egg whites, either. Everything good for you, i.e. the vitamins, is in the yolk.&lt;/li&gt;
&lt;li&gt;It&amp;rsquo;s the fat and protein in foods that make you feel full. So if you get rid of all the fat and half the protein, you&amp;rsquo;re going to be hungry sooner. That means I&amp;rsquo;ll be at work and probably eat junk instead of making it to lunch.&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Is There A Plan?&lt;/h2&gt;

&lt;p&gt;Yes, there is. I hesitate to say this online, because now there&amp;rsquo;s a digital record of it, but I would like to weigh 175#. Yes, that&amp;rsquo;s 24# less than where I am now, and 4# lower than I&amp;rsquo;ve ever been before. I know it&amp;rsquo;s &lt;em&gt;simply&lt;/em&gt; a matter of eating the right things and working out the right way. I know I am capable of meeting this goal, as long as I keep my head in the right place.&lt;/p&gt;

&lt;p&gt;Also, I want to be able to make it through a &lt;a href="http://www.mensfitness.com/training/endurance/crossfit-wod-fran"&gt;Fran workout&lt;/a&gt; with 95# on the barbell and no elastic bands for the pull-ups.&lt;/p&gt;

&lt;p&gt;So here&amp;rsquo;s to being, and staying, positive.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/jlluJGHk94E" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2012/12/29/eating-eggs-lifting-weights-and-pushing-pedals/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Ruby: Explictly Initializing A Value To False]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/YplBA2C3dIo/" />
    <updated>2012-12-18T10:00:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2012/12/18/ruby-explictly-initializing-a-value-to-false</id>
    <content type="html">&lt;p&gt;I had a bit of a stupid moment this morning. I got caught up in it, and the bug took me longer than it should to figure out. &lt;strong&gt;Do you see my bug?&lt;/strong&gt;&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# widget.rb - version 1&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Widget&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kp"&gt;attr_accessor&lt;/span&gt; &lt;span class="ss"&gt;:title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:column&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:closeable&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;alias&lt;/span&gt; &lt;span class="ss"&gt;:closable?&lt;/span&gt; &lt;span class="ss"&gt;:closable&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="vi"&gt;@title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:title&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="vi"&gt;@content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:content&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="vi"&gt;@columnn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:column&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="vi"&gt;@closable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:closable&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Basically, I&amp;rsquo;m setting default values. Not a big deal, right? But then I forgot that nil acts just a little bit differently in Ruby than the rest. If no value for &lt;code&gt;:closable&lt;/code&gt; is given, default the value to true. Seems easy and correct, right? Yes, that spec would pass. So does the test where you set the value to true.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;initializes closeable to true when no value is given&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Widget&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;closabled?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="n"&gt;be_true&lt;/span&gt;  &lt;span class="c1"&gt;# pass&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;initializes closeable to true when explicitly set to true&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Widget&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="n"&gt;closable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;closabled?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="n"&gt;be_true&lt;/span&gt;  &lt;span class="c1"&gt;# pass&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Unfortunely, when you initialize to false, it fails.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;initializes closeable to true when explicitly set to false&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;widget&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="no"&gt;Widget&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;new&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="n"&gt;closable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="n"&gt;widget&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;closabled?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="n"&gt;be_false&lt;/span&gt;  &lt;span class="c1"&gt;# FAIL!&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;And the answer is obvious: both nil and false return false in Ruby. Duh! That&amp;rsquo;s in the first chapter of Ruby. In this statement, &lt;strong&gt;the value will always be set to true!&lt;/strong&gt;&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# when x is true   =&amp;gt; left side of || is returned   =&amp;gt; true&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# when x is nil    =&amp;gt; right side of || is returned  =&amp;gt; true&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# when x is false  =&amp;gt; right side of || is returned  =&amp;gt; true&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Oops!&lt;/p&gt;

&lt;p&gt;The solution isn&amp;rsquo;t too bad, I just needed to be more explicit. If &lt;code&gt;:closable&lt;/code&gt; has a value or is nil, then use true; otherwise, use false.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="vi"&gt;@closable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:closable&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:closable&lt;/span&gt;&lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="n"&gt;nil?&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kp"&gt;false&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;And this is why we write tests: to find the times when we are being stupid.&lt;/p&gt;

&lt;p&gt;But now I have a problem: that is some damn ugly code. And I do not like ugly code. I suppose that&amp;rsquo;s just the way it is with the ternary operator, anything more complicated than &lt;code&gt;y = x ? a : b&lt;/code&gt; is just hard on the eyes.&lt;/p&gt;

&lt;h2&gt;Extending Object&lt;/h2&gt;

&lt;p&gt;Since Ruby is extensible, we can extend &lt;code&gt;Object&lt;/code&gt;. It certainly makes the initializer more obvious. And I&amp;rsquo;m a big fan of obvious code. The specs are really easy to write, too.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;span class='line-number'&gt;16&lt;/span&gt;
&lt;span class='line-number'&gt;17&lt;/span&gt;
&lt;span class='line-number'&gt;18&lt;/span&gt;
&lt;span class='line-number'&gt;19&lt;/span&gt;
&lt;span class='line-number'&gt;20&lt;/span&gt;
&lt;span class='line-number'&gt;21&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Object&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;true_or_nil?&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="nb"&gt;self&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;nil?&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# new initializer&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="vi"&gt;@closable&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="ss"&gt;:closable&lt;/span&gt;&lt;span class="o"&gt;].&lt;/span&gt;&lt;span class="n"&gt;true_or_nil?&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="c1"&gt;# specs&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;returns true for true_or_nil? when value is true&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kp"&gt;true&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;true_or_nil?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="n"&gt;be_true&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;returns false for true_or_nil? when value is false&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kp"&gt;false&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;true_or_nil?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="n"&gt;be_false&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="n"&gt;it&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;returns true for true_or_nil? when value is nil&amp;quot;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kp"&gt;nil&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;true_or_nil?&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;should&lt;/span&gt; &lt;span class="n"&gt;be_true&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Okay, that&amp;rsquo;s not too bad.&lt;/p&gt;

&lt;h2&gt;What About Hash.merge?&lt;/h2&gt;

&lt;p&gt;So there&amp;rsquo;s another way to initialize our widget, and that&amp;rsquo;s by creating a constant of default values.&lt;/p&gt;

&lt;figure class='code'&gt; &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;span class='line-number'&gt;6&lt;/span&gt;
&lt;span class='line-number'&gt;7&lt;/span&gt;
&lt;span class='line-number'&gt;8&lt;/span&gt;
&lt;span class='line-number'&gt;9&lt;/span&gt;
&lt;span class='line-number'&gt;10&lt;/span&gt;
&lt;span class='line-number'&gt;11&lt;/span&gt;
&lt;span class='line-number'&gt;12&lt;/span&gt;
&lt;span class='line-number'&gt;13&lt;/span&gt;
&lt;span class='line-number'&gt;14&lt;/span&gt;
&lt;span class='line-number'&gt;15&lt;/span&gt;
&lt;span class='line-number'&gt;16&lt;/span&gt;
&lt;span class='line-number'&gt;17&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='ruby'&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Widget&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="kp"&gt;attr_accessor&lt;/span&gt; &lt;span class="ss"&gt;:title&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:column&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;:closable&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;alias&lt;/span&gt; &lt;span class="ss"&gt;:closable?&lt;/span&gt; &lt;span class="ss"&gt;:closable&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="no"&gt;DEFAULTS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;&amp;quot;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="n"&gt;closable&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kp"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;initialize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;{})&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="no"&gt;DEFAULTS&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;merge&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;each&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;      &lt;span class="nb"&gt;instance_variable_set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:&amp;quot;@&lt;/span&gt;&lt;span class="si"&gt;#{&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="ss"&gt;&amp;quot;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;    &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;This is a pretty neat solution, too. It&amp;rsquo;s gets a little into the metaprogramming capabilities of Ruby. First, all of the specs still pass. Second, what you&amp;rsquo;re doing is still incredible obvious. Third, you can access &lt;code&gt;Widget::DEFAULTS&lt;/code&gt; if you really wanted to know what the default values were for an object. Fourth, you didn&amp;rsquo;t &lt;a href="http://en.wikipedia.org/wiki/Monkey_patch"&gt;monkey patch&lt;/a&gt; the &lt;code&gt;Object&lt;/code&gt; object.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/YplBA2C3dIo" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2012/12/18/ruby-explictly-initializing-a-value-to-false/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[The Three Types of Technical Debt]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/JGqeIIrfz-E/" />
    <updated>2012-12-07T11:04:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2012/12/07/the-three-types-of-technical-debt</id>
    <content type="html">&lt;p&gt;&lt;em&gt;This was originally posted on my company&amp;rsquo;s blog at &lt;a href="http://blog.fusionalliance.com/blog/caffeine-in-code-out/the-three-types-of-technical-debt"&gt;blog.fusionalliance.com&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;All software has some amount of &lt;a href="http://en.wikipedia.org/wiki/Technical_debt"&gt;technical debt&lt;/a&gt;. And if it doesn’t today, it will tomorrow.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TECHNICAL DEBT WE EXPLICITLY CREATE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We are diligently working on a project. We’re adding unit tests. We’re following proper red-green-refactor methods. But we still need to worry about deadlines. We find code that needs rework, but we don’t have time. We go into our ticketing software and create a new technical debt user story. But time and money are constrained resources. The software ships without resolving that debt. Those stories stay in the backlog, waiting for developer availability.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: I am working on a code base that still accounts for the Indiana time zone, even though it &lt;a href="http://en.wikipedia.org/wiki/Time_in_Indiana"&gt;(mostly) switched to Eastern Time in 2008&lt;/a&gt;. But I’m working on a different user story, and I don’t have time to fix the time zone-related code. Right now, we must recognize that we are &lt;strong&gt;consciously making the choice&lt;/strong&gt; to let irrelevant and out-of-date code live in our software. It works, because our quick-fix was to make Indiana Time function identically to Eastern Time. However, it is plainly wrong. Indiana Time doesn’t even exist, so why is this a setting in the code?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TECHNICAL DEBT WE IMPLICITLY CREATE&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We get better at our jobs. We improve our skills. We learn more about languages and frameworks. In six months, twelve months, or two years we will be better developers than we are today. Sure, the code works, and yes, the tests pass. If you ever have developers that want to redo something they just wrote six months ago, you are looking at implicit technical debt.&lt;/p&gt;

&lt;p&gt;In the first condition, we saw problems but lacked the time to fix them. In this situation, we are creating more debt simply because we don’t know that we’re creating more debt.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: Why are we even dealing with dates in the first place? Even though we get used to working in our current time zone, we should really work as much as we can in &lt;a href="http://en.wikipedia.org/wiki/GMT"&gt;GMT&lt;/a&gt;. The current time is simply GMT plus an offset. Four years ago, I never did this. However, after running into so many time-based problems in my development career, I always think in GMT-plus-offset now, and I never store local times. Unfortunately, there is a lot of code that I wrote prior to this revelation that has not been updated to account for this new-found knowledge.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TECHNICAL DEBT THE WORLD CREATES FOR US&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The world moves on, these days faster than ever. Look at your smart phone. How many apps need to be updated right now? Between when I write this and when it is published, &lt;a href="https://www.google.com/intl/en/chrome/browser/"&gt;Google Chrome&lt;/a&gt; will update itself at least twice. Browsers change and web standards evolve. Operating systems change. Cloud-based vendors offer services that just a few year ago were not available or incredibly expensive. &lt;a href="http://en.wikipedia.org/wiki/MD5"&gt;Old security algorithms&lt;/a&gt; become easily crackable, only to be &lt;a href="http://security.stackexchange.com/questions/4781/do-any-security-experts-recommend-bcrypt-for-password-storage"&gt;replaced by new techniques&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;We didn’t do this to ourselves, but we still must respond. If you have a web site, how does it look on an &lt;a href="http://www.apple.com/ipad/"&gt;iPad&lt;/a&gt;? If you have desktop software, how is it going to work with touch response on &lt;a href="http://windows.microsoft.com/en-US/windows-8/meet"&gt;Windows 8&lt;/a&gt;? Should I have a &lt;a href="http://en.wikipedia.org/wiki/Metro_(design_language"&gt;Metro&lt;/a&gt;) version of my application?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Example: The day Indiana converted to Eastern Time is an example of technical debt the world created for us. We have dozens (hundreds?) of lines of code to work with various time zones relative to Indiana time. It all needs to go away; Indiana Time is obsolete. Any code relying on or accounting for Indiana Time needs to be refactored.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;KEEPING TABS ON YOUR DEBT&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Managing your technical debt is part of managing your product. It’s all about hedging your bets and understanding break-evens. Personally, pain is pain, and I will always be in favor of eliminating pain — for me or the next developer.&lt;/p&gt;

&lt;p&gt;Keep on creating those technical debt stories, and make sure that you are keeping your debt in check.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/JGqeIIrfz-E" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2012/12/07/the-three-types-of-technical-debt/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[Setting up Solr on Tomcat in Mac OS X]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/bQil5cdqhGc/" />
    <updated>2012-12-05T08:45:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2012/12/05/setting-up-solr-on-tomcat-in-mac-os-x</id>
    <content type="html">&lt;p&gt;This is an instructional post on setting up Solr under Tomcat on Mac OS X. I am going to assume that you have &lt;a href="http://mxcl.github.com/homebrew/"&gt;Homebrew&lt;/a&gt; installed because it makes everything so much easier. If you don&amp;rsquo;t have Homebrew installed, check out their instructions.&lt;/p&gt;

&lt;h2&gt;Installing Tomcat&lt;/h2&gt;

&lt;p&gt;It doesn&amp;rsquo;t get much easier than this. As of this writing, this will install Tomcat version 7.0.33&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ brew install tomcat
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This installs Tomcat to &lt;code&gt;/usr/local/Cellar/tomcat/7.0.33/&lt;/code&gt;. We first want to test that Tomcat is up and running correctly. Let&amp;rsquo;s start the server.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ catalina start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When I type this, I get a lovely bit of output.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Using CATALINA_BASE:   /usr/local/Cellar/tomcat/7.0.33/libexec
Using CATALINA_HOME:   /usr/local/Cellar/tomcat/7.0.33/libexec
Using CATALINA_TMPDIR: /usr/local/Cellar/tomcat/7.0.33/libexec/temp
Using JRE_HOME:        /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
Using CLASSPATH:       /usr/local/Cellar/tomcat/7.0.33/libexec/bin/bootstrap.jar:/usr/local/Cellar/tomcat/7.0.33/libexec/bin/tomcat-juli.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Very nice! Let&amp;rsquo;s check out the page at &lt;a href="http://localhost:8080"&gt;http://localhost:8080&lt;/a&gt;, just to make sure that everything is working as expected.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://jarrettmeyer.com/images/content/2012/12-dec/tomcat-on-localhost.png" title="Tomcat on localhost" &gt;&lt;/p&gt;

&lt;p&gt;If all of that is working, then we also want to make sure we can access the app management. To do that, we need to edit the &lt;code&gt;conf/tomcat-users.xml&lt;/code&gt; file, and add allowed management user. This is what my configuration looks like.&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;conf/tomcat-users.xml &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;span class='line-number'&gt;5&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='xml'&gt;&lt;span class='line'&gt;&lt;span class="cp"&gt;&amp;lt;?xml version=&amp;#39;1.0&amp;#39; encoding=&amp;#39;utf-8&amp;#39;?&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nt"&gt;&amp;lt;tomcat-users&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nt"&gt;&amp;lt;role&lt;/span&gt; &lt;span class="na"&gt;rolename=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;manager-gui&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nt"&gt;&amp;lt;user&lt;/span&gt; &lt;span class="na"&gt;username=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;tomcat&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;password=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;tomcat&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;roles=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;manager-gui&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nt"&gt;&amp;lt;/tomcat-users&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;Now, when I request the management page, I should be able to see a listing of applications and server status.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://jarrettmeyer.com/images/content/2012/12-dec/tomcat-server-status.png" title="Tomcat Server Status" &gt;&lt;/p&gt;

&lt;p&gt;Great! Time to move on.&lt;/p&gt;

&lt;h2&gt;Intalling Solr&lt;/h2&gt;

&lt;p&gt;Installing &lt;a href="http://lucene.apache.org/solr"&gt;Solr&lt;/a&gt; is just as easy as installing Tomcat.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ brew install solr
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Thank God for brew formulas. This is so much nicer.&lt;/p&gt;

&lt;p&gt;On my machine, this put Solr in &lt;code&gt;/usr/local/Cellar/solr/4.0.0/&lt;/code&gt;. On my machine, this worked right out of the box with no configuration. You can run Solr natively as a jetty service. Let&amp;rsquo;s try this and see if it&amp;rsquo;s working.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ cd /usr/local/Cellar/solr/4.0.0/libexec/example
$ java -jar start.jar
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will fire up a jetty server on port 8983. Let&amp;rsquo;s test! Navigate your browser to &lt;a href="http://localhost:8983/solr"&gt;http://localhost:8983/solr&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://jarrettmeyer.com/images/content/2012/12-dec/solr-on-localhost.png" title="Solr on localhost" &gt;&lt;/p&gt;

&lt;p&gt;Wow, Homebrew makes this so easy! We don&amp;rsquo;t have any documents, though. So lets load some documents. As it turns out, the Solr example comes with documents, but they haven&amp;rsquo;t been loaded yet. Let&amp;rsquo;s do that.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ pwd
/usr/local/Cellar/solr/4.0.0/libexec/example
$ cd exampledocs
$ ./post.sh *.xml
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will run a script to populate the example collection. We can now use the admin interface to run basic queries. Try something simple, like &lt;code&gt;q=*:*&lt;/code&gt; just to make sure everything is working.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://jarrettmeyer.com/images/content/2012/12-dec/solr-sample-query.png" title="Solr Sample Query" &gt;&lt;/p&gt;

&lt;p&gt;Hey! We&amp;rsquo;ve got docs! Moving on.&lt;/p&gt;

&lt;h2&gt;Getting Solr Running Under Tomcat&lt;/h2&gt;

&lt;p&gt;We&amp;rsquo;ve got Solr working, but it&amp;rsquo;s running under an internal process. We want it to be a Tomcat service on 8080. So how do we get from here to there? As it turns out, this is also pretty easy. We just need to let Tomcat know about Solr&amp;rsquo;s existence. We do this with an XML file. This file is located at &lt;code&gt;/usr/local/Cellar/tomcat/7.0.33/libexec/conf/Catalina/localhost/solr.xml&lt;/code&gt;. (Yes, that&amp;rsquo;s quite a path.)&lt;/p&gt;

&lt;figure class='code'&gt;&lt;figcaption&gt;&lt;span&gt;solr.xml &lt;/span&gt;&lt;/figcaption&gt;
 &lt;div class="highlight"&gt;&lt;table&gt;&lt;tr&gt;&lt;td class="gutter"&gt;&lt;pre class="line-numbers"&gt;&lt;span class='line-number'&gt;1&lt;/span&gt;
&lt;span class='line-number'&gt;2&lt;/span&gt;
&lt;span class='line-number'&gt;3&lt;/span&gt;
&lt;span class='line-number'&gt;4&lt;/span&gt;
&lt;/pre&gt;&lt;/td&gt;&lt;td class='code'&gt;&lt;pre&gt;&lt;code class='xml'&gt;&lt;span class='line'&gt;&lt;span class="cp"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot;?&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nt"&gt;&amp;lt;Context&lt;/span&gt; &lt;span class="na"&gt;docBase=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/usr/local/Cellar/solr/4.0.0/libexec/example/webapps/solr.war&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;debug=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;0&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;crossContext=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;  &lt;span class="nt"&gt;&amp;lt;Environment&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;solr/home&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;java.lang.String&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;/usr/local/Cellar/solr/4.0.0/libexec/example/solr&amp;quot;&lt;/span&gt; &lt;span class="na"&gt;override=&lt;/span&gt;&lt;span class="s"&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;span class='line'&gt;&lt;span class="nt"&gt;&amp;lt;/Context&amp;gt;&lt;/span&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/figure&gt;


&lt;p&gt;As usual, the version numbers for you may be different in the future. But shy of some major changes to Homebrew, this should work for you. Next, restart Catalina.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$ catalina stop
$ catalina start
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When we access the Tomcat management screen, we should now see &lt;code&gt;/solr&lt;/code&gt; listed as an application.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://jarrettmeyer.com/images/content/2012/12-dec/tomcat-manager-with-solr.png" title="Tomcat Manager with Solr listed as an application" &gt;&lt;/p&gt;

&lt;p&gt;If we click the link for &lt;a href="http://localhost:8080/solr"&gt;/solr&lt;/a&gt;, we should be taken to our Solr administrative interface. Here, we show Tomcat with Solr running on port 8080.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://jarrettmeyer.com/images/content/2012/12-dec/tomcat-solr-on-port-8080.png" title="Tomcat-Solr running on port 8080" &gt;&lt;/p&gt;

&lt;p&gt;We can also navigate to &lt;code&gt;collection1&lt;/code&gt; and see our documents that we previously loaded.&lt;/p&gt;

&lt;h2&gt;In Review&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Install Tomcat&lt;/li&gt;
&lt;li&gt;Edit &lt;code&gt;tomcat-users.xml&lt;/code&gt; to configure access to Tomcat management&lt;/li&gt;
&lt;li&gt;Install Solr&lt;/li&gt;
&lt;li&gt;Post example documents&lt;/li&gt;
&lt;li&gt;Edit &lt;code&gt;solr.xml&lt;/code&gt; to configure Solr path&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;That&amp;rsquo;s it! I hope this helps someone.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/bQil5cdqhGc" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2012/12/05/setting-up-solr-on-tomcat-in-mac-os-x/</feedburner:origLink></entry>
  
  <entry>
    <title type="html"><![CDATA[A Week of CrossFit]]></title>
    <link href="http://feedproxy.google.com/~r/jarrettmeyer/~3/v7aZ_-qX9hs/" />
    <updated>2012-11-20T07:14:00-05:00</updated>
    <id>http://jarrettmeyer.com/blog/2012/11/20/a-week-of-crossfit</id>
    <content type="html">&lt;h2&gt;The Battle of the Bulge&lt;/h2&gt;

&lt;p&gt;In my efforts to combat my typical winter bulge, I will be trying out &lt;a href="http://www.crossfit.com"&gt;CrossFit&lt;/a&gt; these upcoming months. Could I just go to the gym myself? Probably. &lt;em&gt;Or probably not.&lt;/em&gt; I think I need something new to keep me motivated.&lt;/p&gt;

&lt;p&gt;CrossFit definitely counts as something new. It&amp;rsquo;s a lot of high-intensity + plus weights training. I&amp;rsquo;ve lifted more in the last week than I have since grade 8.&lt;/p&gt;

&lt;p&gt;Back in grades 7 &amp;amp; 8, I wrestled &amp;amp; played football. I wasn&amp;rsquo;t really aggressive, I wasn&amp;rsquo;t good at it, and everyone else had a lot more experience than I. Then high school came, and I had to choose between marching band or football. Since I&amp;rsquo;m nerd and loved band, I chose band. And that pretty much ended all of working out I did from when I was 14 years old until I turned 24.&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;m used to being sore after a hard run or bike workout. This is quite different. Plus, the gym I found is pretty small and very social. I liked that right away. Much like the triathlon world, everyone is very nice. I think it&amp;rsquo;s the constant endorphin release from working out.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;By the way, that gym is &lt;a href="http://titanfit.com/"&gt;TitanFit&lt;/a&gt;, just off Girls School Road, if you&amp;rsquo;re on the west side of Indianapolis.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I&amp;rsquo;ve already been told by more than one triathlete that I shouldn&amp;rsquo;t do CrossFit because you can hurt yourself lifting weights. Sure. If you lift too much too soon or sacrifice form for weight or reps, I&amp;rsquo;m sure you can really injure yourself. I know lots of runners with shin splints and knee problems, too. How did they get those? By running too hard or too long too soon, before their bodies were ready. I&amp;rsquo;ve been in a bike wreck that shattered my collarbone, and I&amp;rsquo;ve had friends get in bike wrecks and do far worse damage to themselves. Guess what: nothing is injury-proof.&lt;/p&gt;

&lt;p&gt;But you know what I&amp;rsquo;m really looking forward to? Pullups. I&amp;rsquo;ve never been able to do them. My arm strength-to-body weight ratio has never been sufficient for me to get my fat head up and over the bar. I want that. Losing 20# of ugly fat will help with that. So will adding back 10# of muscle.&lt;/p&gt;

&lt;p&gt;What did we do this week? This week was still about learning how to lift and assessing my strength and fitness.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://jarrettmeyer.com/images/content/success_baby_finished_crossfit_workout_didnt_die.jpg" title="Finished CrossFit Workout; Didn't Die" &gt;&lt;/p&gt;

&lt;h3&gt;Wednesday&lt;/h3&gt;

&lt;p&gt;Initial fitness test. It took me about 9:25, primarily because my arms just crapped out during the pushups.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;500m row
40 air squats
30 situps
20 pushups
10 pullups
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I also had to do a version of the pullup where you jump up from the floor, then use your arms the rest of the way.&lt;/p&gt;

&lt;h3&gt;Thursday&lt;/h3&gt;

&lt;p&gt;Squats. And rowing. I remember doing squats, but I don&amp;rsquo;t for the life of me remember how many or what order. It&amp;rsquo;s kinda all a blur for some reason.&lt;/p&gt;

&lt;h3&gt;Friday&lt;/h3&gt;

&lt;p&gt;Learned push press.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;1000m row
30 push press @ 45#
750m row
20 push press
500m row
10 push press
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Thems are some sore arms.&lt;/p&gt;

&lt;h3&gt;Monday&lt;/h3&gt;

&lt;p&gt;Hooray for running! Something I know how to do. I hope there&amp;rsquo;s more of this!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;800m run
20 dead lift @ 155#
800m run
10 dead lift
800m run
5 dead lift
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, we&amp;rsquo;ll see how this goes. Here&amp;rsquo;s to starting off a kick butt winter.&lt;/p&gt;
&lt;img src="http://feeds.feedburner.com/~r/jarrettmeyer/~4/v7aZ_-qX9hs" height="1" width="1"/&gt;</content>
  <feedburner:origLink>http://jarrettmeyer.com/blog/2012/11/20/a-week-of-crossfit/</feedburner:origLink></entry>
  
</feed>
