Robert Martin’s book Clean Code has been on my to-read list for months now. Browsing the web, I stumbled across this repository of where Ryan McDermott applied the book’s principles to JavaScript. Basically, he made a guide to producing readable, reusable, and refactorable software code in JavaScript.
Although Ryan’s good and bad code examples are written in JavaScript, the basic principles (i.e. “Uncle Bob”‘s Clean Code principles) are applicable to any programming language. At least, I recognize many of the best practices I’d teach data science students in R or Python.
Find the JavaScript best practices github repo here: github.com/ryanmcdermott/clean-code-javascript
Knowing these won’t immediately make you a better software developer, and working with them for many years doesn’t mean you won’t make mistakes. Every piece of code starts as a first draft, like wet clay getting shaped into its final form. Finally, we chisel away the imperfections when we review it with our peers. Don’t beat yourself up for first drafts that need improvement. Beat up the code instead!
Ryan McDermott via clean-code-javascript
Screenshots from the repo:


Here are some of the principles listed, with hyperlinks:
- Use meaningful and pronounceable variable names
- Use the same vocabulary for the same type of variable
- Use searchable names
- Use explanatory variables
- Avoid Mental Mapping
- Don’t add unneeded context
- Use default arguments instead of short circuiting or conditionals
- Function arguments (2 or fewer ideally)
- Functions should do one thing
- Function names should say what they do
- Remove duplicate code
- Don’t use flags as function parameters
- Avoid side effects
- Don’t write to global functions
- Favor functional programming over imperative programming
- Encapsulate conditionals
- Avoid negative conditionals
- Avoid conditionals
But there are many, many more! Have a look at the original repo.
