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).
- Errors: part of the learning curve
- Why I Use Perl: Testing
- Divide Your Automated Testing Efforts
- Automated Browser-based Testing with Clojure
- How to Perform Software Automation Testing - Step by Step Tutorial
Here's how it works 👇
Then get thoughtful letters 💌 on mindsets, tactics, and technical skills for your career.
"Man, love your simple writing! Yours is the only email I open from marketers 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. 👌"
Ready to Stop copy pasting D3 examples and create data visualizations of your own? Learn how to build scalable dataviz components your whole team can understand with React for Data Visualization
Curious about Serverless and the modern backend? Check out Serverless Handbook, modern backend for the frontend engineer.
Ready to learn how it all fits together and build a modern webapp from scratch? Learn how to launch a webapp and make your first 💰 on the side with ServerlessReact.Dev
By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️