Write Clean JavaScript

Over the weekend I discovered a cool repo on GitHub: ryanmcdermott/clean-code-javascript.
It's a great summary of Uncle Bob's timeless programming classic Clean Code, in JavaScript.

Clean Code has definitely been one of the most impactful books on my programming, and having it detailed so clearly and succinctly in JavaScript is very useful. It's important to remember just reading it won't make you better at programming, but thinking about it, identifying the principals, and continually practicing them will.

There is one part where I disagree with Ryan's comments in the repo: code duplication.

When it comes to DRY'ing code (Don't Repeat Yourself), I follow the "Rule of Threes" - I will repeat code up to three times before refactoring it and removing duplication.

There are many times where I have see code that was used in only two or three places be refactored and then never re-used again. This can result in what I consider to be an even greater evil: Premature Optimisation. Once you've used code in more than three places, you've proved that it's a useful and integral part of the codebase, and worthy of clean-up and optimisation.

Re-reading this content was a good reminder of the Manifesto for Software Craftsmanship, something that's sometimes forgotten between deadlines and StackOverflow posts...