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

 <title>Constantly Learning - Brett Hardin</title>
 <link href="http://bretthard.in/atom.xml" rel="self"/>
 <link href="http://bretthard.in/"/>
 <updated>2019-04-09T21:38:07+00:00</updated>
 <id>http://bretthard.in/</id>
 <author>
   <name>Brett Hardin</name>
   <email>hardin.brett@gmail.com</email>
 </author>

 
 <entry>
   <title>Always Be Knolling</title>
   <link href="http://bretthard.in/posts/always-be-knolling"/>
   <updated>2016-01-15T00:00:00+00:00</updated>
   <id>http://bretthard.in/posts/always-be-knolling</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	

   </content>
 </entry>
 
 <entry>
   <title>Joshua Tree</title>
   <link href="http://bretthard.in/adventure/joshua-tree"/>
   <updated>2016-01-05T00:00:00+00:00</updated>
   <id>http://bretthard.in/adventure/joshua-tree</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	

   </content>
 </entry>
 
 <entry>
   <title>Apple Pencil</title>
   <link href="http://bretthard.in/post/apple-pencil"/>
   <updated>2015-09-10T00:00:00+00:00</updated>
   <id>http://bretthard.in/post/apple-pencil</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	

   </content>
 </entry>
 
 <entry>
   <title>Getting Things Done</title>
   <link href="http://bretthard.in/post/getting-things-done"/>
   <updated>2015-06-25T00:00:00+00:00</updated>
   <id>http://bretthard.in/post/getting-things-done</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	

   </content>
 </entry>
 
 <entry>
   <title>Automatically Clear Your Downloads Directory</title>
   <link href="http://bretthard.in/post/automatically-clear-your-downloads-directory"/>
   <updated>2015-03-17T00:00:00+00:00</updated>
   <id>http://bretthard.in/post/automatically-clear-your-downloads-directory</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	

   </content>
 </entry>
 
 <entry>
   <title>Information Is Not Secure</title>
   <link href="http://bretthard.in/post/information-is-not-secure"/>
   <updated>2015-03-05T00:00:00+00:00</updated>
   <id>http://bretthard.in/post/information-is-not-secure</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	

   </content>
 </entry>
 
 <entry>
   <title>Use The Defaults</title>
   <link href="http://bretthard.in/post/use-the-defaults"/>
   <updated>2014-11-11T00:00:00+00:00</updated>
   <id>http://bretthard.in/post/use-the-defaults</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	&lt;p&gt;When I was 13-years old I competed in the Blockbuster video game championships.
The start of the competition was to be the best in your hometown. I destroyed
the local competition by beating both secret levels in Sonic the Hedgehog 2.
Upon winning Blockbuster invited me to represent my city in the state finals.&lt;/p&gt;

&lt;p&gt;The game we would be playing was NBA Jam. The competition would be a single-
elimination head-to-head tournament.&lt;/p&gt;

&lt;p&gt;Upon winning the hometown championship you received a free game. I chose NBA Jam
to hone my virtual basketball skills before the state competition.&lt;/p&gt;

&lt;p&gt;For those of you that don’t play video games, you can customize your controls.
On a Sega Genesis system there are three buttons: A, B, and C. I didn’t like the
default setup on NBA Jam which is as follows:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;* A - Shoot
* B - Turbo
* C - Pass
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;I preferred the following:&lt;/p&gt;

&lt;div class=&quot;highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;* A - Turbo
* B - Pass
* C - Shoot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Before changing the defaults, I of course, read the rules for the state finals.
It explained that changing the button configurations was optional. I read this
as: it is optional for the player to change controls.&lt;/p&gt;

&lt;p&gt;The state final was an all-day event. When I showed up to play my first game I
explained to the man setting up the station that I needed to change the
controls. He responded that it was an optional rule and the coordinators chose
to use defaults.&lt;/p&gt;

&lt;p&gt;“Optional in this case meant it was up to the tournament coordinators. The
“coordinators crushed my chances of winning because I had not learned to use the
“default controls.&lt;/p&gt;

&lt;p&gt;Although I attempted to play the best I could, with controls I didn’t know, my
opponent destroyed me.&lt;/p&gt;

&lt;p&gt;Losing this way was demoralizing. I didn’t know how good I was because I
couldn’t use my custom controls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Since losing, I never change defaults.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;From that moment forward, any game that I played, I would only use defaults. I
completely ignore control configuration screens. I don’t even open them.&lt;/p&gt;

&lt;p&gt;I recently changed from Bash shell to zsh. Upon making the transition I asked my
colleagues which themes they use for oh-my-zsh. Sean sent me this screenshot:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/sean-screenshot.png&quot; alt=&quot;sean-screenshot&quot; /&gt;&lt;/p&gt;

&lt;p&gt;I was immediately turned off because it didn’t look like a default shell. I
already knew zsh, by default, didn’t look like this because I had already
installed it and had it working. But, if I had seen this screen first, I would
have not installed zsh.&lt;/p&gt;

&lt;p&gt;Sean has all kinds of customizations. A status bar at the bottom, a left and
right column, and even a quote. When moving to a remote system (through ssh)
this type of configuration takes a while to setup. I don’t want to configure a
new remote system to be effective. It takes too long.&lt;/p&gt;

&lt;p&gt;I have some customization, such as git aliases, but Sean’s setup is ridiculous.&lt;/p&gt;

&lt;p&gt;Anywhere I can, I choose vanilla. &lt;strong&gt;When presented with options, use the
defaults.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;P.S. For those curious, I decided on the “muse” theme. Here is what it looks
like:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/assets/images/muse.png&quot; alt=&quot;muse&quot; /&gt;&lt;/p&gt;

   </content>
 </entry>
 
 <entry>
   <title>Chess and Computers</title>
   <link href="http://bretthard.in/post/chess-and-computers"/>
   <updated>2013-08-17T00:00:00+00:00</updated>
   <id>http://bretthard.in/post/chess-and-computers</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	&lt;p&gt;Peter Thiel and Garry Kasparov were recorded having multiple conversations during a day in which they hung out.&lt;/p&gt;

&lt;p&gt;At one point during the video they discuss computing power and speed. &lt;a href=&quot;http://en.wikipedia.org/wiki/Deep_Blue_versus_Garry_Kasparov&quot;&gt;Kasporav known for playing Deep Blue&lt;/a&gt;, a computer designed to play chess, stated that humans associate computing power with chess playing. He believes humans associate chess playing with wisdom.&lt;/p&gt;

&lt;p&gt;As computers get better at playing chess, society thinks that computers are improving at solving all problems. People who play chess, like Kasparov, are assumed to be intelligent because they are good at a game. But, is this true?&lt;/p&gt;

&lt;p&gt;Kasparov dedicated a large portion of his early life to playing chess. He began training at the age of 10. Although he may have had a natural affinity and love of the game, practicing, and studying is what made him great.&lt;/p&gt;

&lt;p&gt;To the layperson, someone who plays chess is deemed intelligent. So, this association naturally expands into computers.&lt;/p&gt;

&lt;p&gt;If a computer can beat a human at something we deem as human and intelligent then they are becoming smarter at everything.&lt;/p&gt;

&lt;p&gt;There are many things that computers don’t do well. Computer scientist group these problems into the &lt;a href=&quot;http://cdixon.org/2012/02/21/the-p-vs-np-problem/&quot;&gt;category of NP problems&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Humans, including programmers and visionaries, are very poor at &lt;a href=&quot;http://coding.abel.nu/2012/06/programmer-time-translation-table/&quot;&gt;estimating time to complete complex tasks&lt;/a&gt;. We overestimate things we don’t understand and underestimate things that we do.&lt;/p&gt;

&lt;p&gt;Until we have a technology breakthrough (e.g. quantum computing) we will still have machines which are poor at solving a certain class of problem.&lt;/p&gt;

&lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/9rOvEPYNEsc?feature=player_detailpage&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;

&lt;h3 id=&quot;stamina-to-continue&quot;&gt;Stamina to Continue&lt;/h3&gt;

&lt;blockquote&gt;
  &lt;p&gt;If you have the stamina to continue, the opponent will collapse.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;ul&gt;
    &lt;li&gt;Garry Kasparov&lt;/li&gt;
  &lt;/ul&gt;
&lt;/blockquote&gt;

&lt;p&gt;At one point, Thiel asks Kasparov what strategy he uses when playing simultaneous games. Kasparov says he focuses on keeping each game equally matched and waiting for his opponents to make a miscalculation.&lt;/p&gt;


   </content>
 </entry>
 
 <entry>
   <title>Use Other People's Code</title>
   <link href="http://bretthard.in/post/use-other-peoples-code"/>
   <updated>2013-08-04T00:00:00+00:00</updated>
   <id>http://bretthard.in/post/use-other-peoples-code</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	&lt;p&gt;Some developers use other people’s code while others write programs which do the same thing themselves. I’ve been fortunate enough to work for two startups who’ve had founding developers who were able to write code incredibly fast. However, faster isn’t always right.&lt;/p&gt;

&lt;p&gt;A common attribute of developers who code fast is they roll their own code instead of using known software which does the same thing. Their reasoning is that they can build it faster than reading the documentation and implementing someone else’s code. Although this could be accurate it can either hurt the development team later on or &lt;a href=&quot;http://bretthard.in/2009/09/insecure-cryptographic-storage/&quot;&gt;it shouldn’t be done in the first place&lt;/a&gt;. Speed and iteration in a startup is the second most important thing for a startup behind customer development.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://swizec.com/blog/always-look-for-the-gem/swizec/6287&quot;&gt;Swizec Teller&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;After hours of debugging I finally traced the issue down to spaces in item names. Turns out id=”a word” doesn’t work. Who’d’ve thought? (hint: everyone)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;But that’s an easy fix right? The point is, all you have to do is replace spaces with dashes. Simple.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;But you’re wrong. You are creating a slug. &lt;strong&gt;It looks easy, but is actually very complicated. Luckily others have solved the problem already. Better than you.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the major problem. Developers that are able to code amazing software are often the ones who don’t really grasp the concept that someone else is better than them. They understand the idea, but they don’t grasp the concept.&lt;/p&gt;

&lt;p&gt;He continues:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;&lt;strong&gt;Why spend an hour looking for and learning how to use a gem instead of solving the problem in two minutes of coding?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That is the exact thinking of these types of developers. Don’t be this type of developer.&lt;/p&gt;

&lt;p&gt;Developers who open source the code you are going to rewrite will continue supporting the code. Once you develop the code, you won’t maintain it or look for areas to optimize. The developer that has open sourced their code to do the same thing you are solving will. Other developers will contribute to the solution also. It’s like having a bunch of developers on your team that you don’t have to pay.&lt;/p&gt;

&lt;p&gt;In addition, when new developers join your team they won’t have to learn your custom code base. They may already have experience with the open source solution which gives you a huge leg up in terms of speed of development.&lt;/p&gt;

&lt;p&gt;I’m sure other industries have this same problem. It’s hard to find a good analogy, but the first that comes to mind is bakers. If a baker decides he wants to create a cookie, he just grabs the ingredients needed and starts baking. However, the &lt;a href=&quot;http://www.neimanmarcuscareers.com/story/recipe.shtml&quot;&gt;Neiman Marcus cookie&lt;/a&gt; is pretty good and will get the job done. Why doesn’t he just use that recipe instead?&lt;/p&gt;

   </content>
 </entry>
 
 <entry>
   <title>Foundational Rules of Code Testing</title>
   <link href="http://bretthard.in/post/foundational-rules-of-code-testing"/>
   <updated>2013-07-24T00:00:00+00:00</updated>
   <id>http://bretthard.in/post/foundational-rules-of-code-testing</id>
   <content type="html">
   	&lt;img src=&quot;&quot; width="400px" /&gt;
   	&lt;p&gt;I’ve been doing a lot of refactoring tests lately and have identified some anti-patterns. From talking with other developers it seems some of these rules are widely understood, while others aren’t. Even though something is understood, it doesn’t mean the community has adopted it. I know a lot of programmers who don’t even write tests.&lt;/p&gt;

&lt;p&gt;If you are serious about programming and your test suite these are the rules I’ve identified which should always be followed.&lt;/p&gt;

&lt;h2 id=&quot;dont-have-more-than-one-assertion-per-test&quot;&gt;Don’t have more than one assertion per test&lt;/h2&gt;

&lt;p&gt;This is a fairly simple one. If you are testing more than one thing or state in a test, don’t. Break it up into two tests. There are a few reasons for this. First, it’s easier to trouble shoot the failing test.&lt;/p&gt;

&lt;p&gt;Replace this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'has three ingredients'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;ingredients&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;no&quot;&gt;Shortbread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ingredients&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;ingredients&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;should&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;sugar&quot;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;ingredients&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;should&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;butter&quot;&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;ingredients&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;should&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;==&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;flour&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;With this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'has three ingredients'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;no&quot;&gt;Shortbread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ingredients&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;size&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;should&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;be&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

&lt;span class=&quot;n&quot;&gt;describe&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'ingredients'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
  &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'include eggs'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;Shortbread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ingredients&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;eggs&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'include butter'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;Shortbread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ingredients&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;butter&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;

  &lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'include flour'&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do&lt;/span&gt;
    &lt;span class=&quot;no&quot;&gt;Shortbread&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ingredients&lt;/span&gt; &lt;span class=&quot;kp&quot;&gt;include&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;flour&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
  &lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;end&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;Note: If order is important, you could also check this under ingredients description. This is a good thing to point out in the earlier test though. Is order important? If another developer comes along and has the first test to work with, who knows…&lt;/p&gt;

&lt;h2 id=&quot;dont-start-your-test-descriptions-with-the-word-should&quot;&gt;Don’t start your test descriptions with the word ‘should’&lt;/h2&gt;

&lt;p&gt;&lt;a href=&quot;/post/tests-should-not-begin-with-should&quot;&gt;It is implied the test should do something&lt;/a&gt;. Otherwise, it wouldn’t be a test. &lt;a href=&quot;http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html&quot;&gt;Rather than use the word should, start the description with a present-tense verb&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Replace this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'should have three ingredients'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;p&gt;With this:&lt;/p&gt;

&lt;figure class=&quot;highlight&quot;&gt;&lt;pre&gt;&lt;code class=&quot;language-ruby&quot; data-lang=&quot;ruby&quot;&gt;&lt;span class=&quot;n&quot;&gt;it&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'has three ingredients'&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/figure&gt;

&lt;h2 id=&quot;dont-overload-classes-or-class-methods-in-tests&quot;&gt;Don’t overload classes or class methods in tests&lt;/h2&gt;

&lt;p&gt;It can be tempting to overload a class method in your test. Rather than having the method be called, you overload it to make sure it isn’t called. This can have unintended side effects.&lt;/p&gt;

&lt;p&gt;If a test which overloads a method is called with a test that tests this method, bad things will ensue.&lt;/p&gt;

&lt;p&gt;Use method stubbing for this and localize it to the individual test. Don’t let the test bleed into other tests.&lt;/p&gt;

&lt;h2 id=&quot;dont-use-global-variables&quot;&gt;Don’t use global variables&lt;/h2&gt;

&lt;p&gt;I normally see this used in conjunction with overloading class methods. Although a programming language gives you the tools, it doesn’t mean you have to use it. I like languages that give you enough rope to hang yourself with, however, when junior developers develop in these languages, bad things can happen.&lt;/p&gt;

&lt;h2 id=&quot;tests-should-be-independent&quot;&gt;Tests should be independent&lt;/h2&gt;

&lt;p&gt;One test should not rely on another test. Each test should be able to ran independently. Rspec and other testing frameworks provide ways to build upon the state of the test but still allow the test to be executed independently. Nothing can get your test suite in more trouble than breaking this rule.&lt;/p&gt;

&lt;p&gt;One good way to ensure your test suite does this is by running the tests in random order. Rspec has supported &lt;a href=&quot;http://blog.davidchelimsky.net/blog/2012/01/04/rspec-28-is-released/&quot;&gt;running tests in random order&lt;/a&gt; since 2.8. Check your test suite documentation on how to do this.&lt;/p&gt;

&lt;h2 id=&quot;tests-should-leave-state-the-way-it-was-found&quot;&gt;Tests should leave state the way it was found&lt;/h2&gt;

&lt;p&gt;This is one of the hardest things to do. If one test sets up a database state, make sure you unwind that database state on tear down. If not, you, or someone on your team, will write a test which relies on this database state. Once tests are written this way, it’s hard to unwind.&lt;/p&gt;

&lt;p&gt;Have I missed anything? What rules do you use while writing tests?&lt;/p&gt;


   </content>
 </entry>
 

</feed>
