---
description: >-
  If you want to write good code, focus on readability. Code that's
  incomprehensible and unreadable is like garbage that can't be recycled.
---

# 1. Underestimating the importance of code quality

###

Think of your program as parts communicating through code. Bad code is like bad communication. As **John Woods** said

"Write your code as if it will be accompanied by an aggressive psychopath who knows where you live."

>

\
Even the "little things" matter. Inconsistent capitalization and indentation can be a sign of sloppy programming. It's more important than you might think.

```
tHIS is
  WAY MORE important
than
         you think
```

\
Avoid long strings. Lines longer than 80 characters are hard to read. Use tools like ESLint and Prettier for JavaScript to clean up your code.

Keep track of the number of lines in your functions and files. Divide your code into small, understandable, and testable parts. A function longer than 10 lines is too long.

Avoid double negation. It's very not not not good.

Give your variables meaningful, informative, and unambiguous names. Don't use short, general, or type-based names.\


> As Phil Carlton said, "There are only two really hard things in computer science: cache invalidation and naming things."\
> \
> Use constants with meaningful names to store primitives. For example, if you need to use the number 12 somewhere, define a constant like this:\
> \
>

```
const monthsInYear = 12; 
```

\
Don't use shortcuts in your code to save time. Face problems head-on and defeat them with the right code.

In most cases, shorter code is better than longer code. But don't sacrifice readability for brevity. Avoid using ternary operators to keep your code to one line. And don't add unnecessary code either. Removing unnecessary code is the best way to improve any program.\


> As Bill Gates said, "Measuring programming progress by lines of code is like measuring aircraft building progress by weight."
>
> Avoid excessive conditional logic. Often, what you want to write through a conditional can be expressed differently, which can improve the readability of your code. Don't worry about optimization until it's necessary. Avoid assignments and Yoda-style conditions.
>
>
