Hate-Driven Development

Most development at Atomic gets done in Vim, but occasionally we get work that better fits the use of Visual Studio or IntelliJ IDEA. When we do, we take advantage of the intelligent code features of these IDEs. Despite occasionally feeling slower in .NET or Java than in, say, Ruby or CoffeeScript, one way to keep up the pace is with a technique we call Hate-Driven Development.

m not talking about this kind of HDD, where you hate the code. At Atomic, HDD refers to the editor hating you. Our sense of the word refers to the horror-inducing full-saturation red highlights that appear all over the code when you use instances of unknown classes or call methods that don’t yet exist:

By letting these hints guide the use of code helpers in the editor, you can drive a feature from failing test to completion with a lot less manual typing of overwrought syntax. The technique goes something like this:

  1. Write the test
  2. The class under test doesn’t exist; auto-create it
    • The method under test doesn’t exist; auto-declare it with infered parameter types
    • The collaborating objects aren’t available; inject instances or assign fields
    • Auto-create expected method stubs on collaborating objects, etc.
  3. Run the test
  4. The test fails
  5. Write the method
  6. The test passes

Getting used to letting go of future concerns and writing speculative code into tests takes practice. Once mastered, this approach lets me focus on what a feature needs to do, instead of all the “boilerplate” code I need to write before writing the feature and getting a passing test. HDD works even better when paired with interaction-based TDD and Presenter- (or ViewModel-) First patterns.

Fortunately, I don’t miss this intelligent hinting when I’m writing features in higher-level, dynamic languages. The need for boilerplate tends to be less anyway, so the process of speculating a test and then writing signatures to make the test fail isn’t as long-winded and repetitive.

Next time you are using a type-checked language or an intelligent editor like IntelliJ, try HDD. You might learn to love the editor telling you what to do next.

“Good. Use your aggressive feelings, boy. Let the hate flow through you.” – The Emperor