May 10, 2016
From, with love.

Distraction-Driven Development

Hi everyone,

When you're coding, how many windows do you have open on your screen? You have your text editor, but what else? A web browser? Maybe your Twitter feed? An IM or IRC window? Facebook? Do you have email notifications pop up when a new mail arrives? Are you monitoring more than one email address for new email? If you're anything like most programmers, you're doing all of this, and you think you're really productive because you're pulling it off.

In reality, all of those extra windows are a distraction. It's well-known that humans believe they can multitask when in fact they can not. Our brains can't actually focus on more than one thing at a time, so what you're really doing is switching your single thread to a different task (not unlike JavaScript itself). Doing so comes with a cost, and that cost means you're getting things done more slowly than you would have had you attempted the tasks in serial instead of in parallel.

When I discovered this a few years ago, I changed the way I worked. I, too, used to have a Twitter app and Facebook open all the time. I'd have 30 browser tabs so whenever I got bored, I could switch to something to take my mind off of it. My email notifications constantly interrupted me with mundane and often unimportant messages. And now? I generally have three windows open: a text editor, the console, and a web browser. I close tabs for anything I don't need immediately (including email and Twitter), and I use the Chrome Momentum plugin to remind me of what I am supposed to be focusing on when I open a new tab.

Making these changes, along with working in a quiet environment, allowed me to continue to be productive even as my brain was being attacked by Lyme disease (making concentration even more difficult).

At first, focusing on just one thing feels uncomfortable -- we are so used to context switching that sitting still just doesn't feel right. But if you give it some time, you may just find yourself being a lot more productive than you ever thought possible.

Be well.

JavaScript WeeklySponsor: O'Reilly Docker Online Course
Join Sean Kane for a hands-on, in-depth introduction to Docker, June 28-29. 

Recommended Links

What is HTTP/2? (article)
Do you know what HTTP/2 is? Or what browsers support it? Or how it's different? This very long, but very good article explores all of the details around HTTP/2. This is a great resource to keep bookmarked for whenever someone needs a primer on HTTP/2.

Turbocharged JavaScript Refactoring with Codemods (article)
Let's say you have a fairly large code base and you need to change multiple object literals into ECMAScript 6 classes - how would you do that? It's definitely too much work to do by hand, and that's where codemods come in. Codemods let you define syntax changes to make in files and then automatically apply those changes. The changes are safe because they make use of an AST.

Caching Best Practices and max-age Gotchas (article)
The worst kept secret about HTTP is that cache control headers rarely do what you expect them to do. This in-depth article explains some of the best practices regarding cache control and how the browser and server communicate. There's also some discussion about how service workers fit into the picture.


Recommended Book

If you haven't yet read Freakonomics, then you might be one of a very few people. The book turns what we know about the world on its head by using economic theory to explain everyday occurrences. Is it more dangerous to have a gun in the house or have a swimming pool? Is the massive drop in crime in the U.S. attributable to better policing, or something else? How can you tell if teachers are cheating on standardized tests by filling in answers for their students? This book gives you a different perspective on a lot of things that you think you know and understand, showing that a different perspective (and some numbers) can show a reality that you never dreamed would be possible.

Recently on NCZOnline

ES6 module loading: More complicated than you think
One of the most long-awaited features of ECMAScript 6 is the formal definition of modules as part of the language. For years, JavaScript developers have struggled with organizing their code and needing to decide between alternate ad-hoc module formats like RequireJS, AMD, and CommonJS. Formally defining modules as part of JavaScript will eliminate a lot...

Mimicking npm script in Node.js
I'm a big fan of npm scripts[1] and have been using them in all of my projects instead of a standalone build system. The feature I like the most from npm scripts is the ability to run command line executables that are installed in your project's node_modules/.bin directory. That allows you to, for example, install...

Reflections on ESLint's success
It's hard for me to believe, but I first conceived and created ESLint[1] in June 2013 and first announced it's availability in July 2013[2]. As frequent readers might recall, the primary goal of ESLint was to create a linter with rules that could be loaded at runtime. I had seen some problems in our JavaScript...


Love this newsletter? Hate it? Have suggestions for how to make it better? When you subscribe to the newsletter, you can just reply to send in feedback.

Ready to subscribe?

Join 2,000 others and subscribe to get the newsletter delivered to your inbox every other Tuesday. 
If you enjoy this newsletter and would like to support my work (including the newsletter, my blog, my books, and ESLint), please consider becoming a patron. I provide a lot of free content and your support allows me to spend more time doing so, and there are great rewards for patrons.
Copyright © 2016 Nicholas C. Zakas, All rights reserved.

unsubscribe from this list    update subscription preferences