Swizec Teller - a geek with a hatswizec.com

    Simple trick that lets you code twice as fast

    Basic idea from THE Bret Victor talk

    Immediate feedback.

    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?

    Mocha automated automated testing

    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:

    1. Write some code
    2. Hop into a console of some sort
    3. Possibly compile things
    4. Run the test suite
    5. Wait while it runs
    6. Give in to the urge to quickly check twitterredditfacebooksomething
    7. 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).

    Enhanced by Zemanta

    Did you enjoy this article?

    Published on October 8th, 2012 in Automation, Programming, Quality assurance, Test automation, Test suite, Uncategorized

    Learned something new?
    Want to become an expert?

    Here's how it works 👇

    Leave your email and I'll send you thoughtfully written emails every week about React, JavaScript, and your career. Lessons learned over 20 years in the industry working with companies ranging from tiny startups to Fortune5 behemoths.

    Join Swizec's Newsletter

    And get thoughtful letters 💌 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. 👌"

    ~ Ashish Kumar

    Join over 14,000 engineers just like you already improving their careers with my letters, workshops, courses, and talks. ✌️

    Have a burning question that you think I can answer? I don't have all of the answers, but I have some! Hit me up on twitter or book a 30min ama for in-depth help.

    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

    Want to brush up on your modern JavaScript syntax? Check out my interactive cheatsheet: es6cheatsheet.com

    By the way, just in case no one has told you it yet today: I love and appreciate you for who you are ❤️

    Created bySwizecwith ❤️