No really, it’s that simple.
Most of our a developer’s revolves around verifying code. After hitting the limit of how fast you can type, the only way to think faster is getting feedback instantly.
There’s actually two parts to this trick.
1. Automated testing
First of all, you should write tests. No need for full on TDD writing tests before writing code, just have tests, any tests. Because eventually you will want to know if this thing you’ve just coded works.
Your first test is: does it run?
The next test is: does it do what it’s supposed to?
Without an automated test suite this one is tricky. It takes ages. Decades compared to how easy it was to write. At worst, you have to check your whole program after every change. Good design alleviates a lot of this burden due to isolation, but still … effort.
I still remember when every change meant some 20 minutes of clicking around to check if things worked. And I only remembered to click around the thing I just changed, never you mind any ripple effects in the codebase.
Automated testing reduces those 20 minutes to, say, 30 seconds.
Your life becomes:
- Write some code
- Hop into a console of some sort
- Possibly compile things
- Run the test suite
- Wait while it runs
- Give in to the urge to quickly check twitterredditfacebooksomething
- Go back to coding long after the tests finished
Great, it’s just taken a minute (not counting twitterredditfacebooksomething time) to find out if something works. I do this every ~5 minutes, that means a waste of 10 minutes per every hour worked.
2. Automated automated testing
One hour and twenty minutes every full workday.
Man, that’s some non-negligible time right there!
Then again, I’ve got an automated test suite, why am I running it manually? Wouldn’t it be better if something ran the test suite every time I hit Ctrl+S?
And that’s exactly how it’s supposed to be!
Let automated testing run automatically and just glance at the results every so often. You won’t break concentration, you won’t be tempted to check twitter while the tests run, you won’t have to get out of your text editor.
Right now I use two tools to do this (and am looking for more)
Mocha‘s got a wonderful -w option for running node.js tests – it watches files for changes and reruns the suite every time you save. And Mocha is just generally wonderful, but that’s a different post.
For frontend development, I’m using Live CSS Mod - a Chrome extension, which refreshes a page every couple of seconds. But it’s smart enough to do this in the background and only show the changes if there’s anything different. This means you don’t lose state all the time because that would be annoying.
Now all I need are these sorts of tools for the other stacks I’m using. (Django/python and Haskell).
Need a freelance developer? Email me!