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.
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.
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).
I write articles with real insight into the career and skills of a modern software engineer. "Raw and honest from the heart!" as one reader described them. Fueled by lessons learned over 20 years of building production code for side-projects, small businesses, and hyper growth startups. Both successful and not.
Subscribe below 👇
Join Swizec's Newsletter and get insightful emails 💌 on mindsets, tactics, and technical skills for your career. Real lessons from building production software. No bullshit.
"Man, love your simple writing! Yours is the only newsletter I open and only blog that I give a fuck to read & scroll till the end. And wow always take away lessons with me. Inspiring! And very relatable. 👌"
Senior Mindset Book
Get promoted, earn a bigger salary, work for top companiesLearn more
Have a burning question that you think I can answer? Hit me up on twitter and I'll do my best.
Who am I and who do I help? I'm Swizec Teller and I turn coders into engineers with "Raw and honest from the heart!" writing. No bullshit. Real insights into the career and skills of a modern software engineer.
Want to become a true senior engineer? Take ownership, have autonomy, and be a force multiplier on your team. The Senior Engineer Mindset ebook can help 👉 swizec.com/senior-mindset. These are the shifts in mindset that unlocked my career.
Curious about Serverless and the modern backend? Check out Serverless Handbook, for frontend engineers 👉 ServerlessHandbook.dev
Want to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz React components your whole team can understand with React for Data Visualization
Did someone amazing share this letter with you? Wonderful! You can sign up for my weekly letters for software engineers on their path to greatness, here: swizec.com/blog
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️