rodolphoasb / clean-code-js

Clean Code Summary with some personal comments.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Clean Code with Javascript

How to measure code quality?

image

How to write Clean Code?

You need to be a Craftsman.

But how to learn craftsmanship?

There are two parts: knowledge and work.

You must gain the knowledge of principles, patterns, practices, and heuristics that a craftsman knows, and you must also grind that knowledge into your fingers, eyes, and gut by working hard and practicing.

Why it's important to keep you code clean?

Bad code kills productivity in the long term, and bad productivity kills software companies.

I think this happens mostly because of two things:

  1. They won't be able to release new features as fast as their competitors;
  2. The general cost of the software increases;

Therefore, keep the code clean should be in the DNA of a software company. The paragraph below makes an awesome analogy with this:

"A building with broken windows looks like nobody cares about it. So other people stop caring. They allow more windows to become broken. Eventually they actively break them. They despoil the facade with graffiti and allow garbage to collect. One broken window starts the process toward decay."

Clean code characteristic

  1. Clean code can be read, and enhanced by a developer other than its original author.
  2. It has unit and acceptance tests.
  3. It has meaningful names.
  4. Clean code does one thing well.
  5. The logic should be straightforward to make it hard for bugs to hide.
  6. The dependencies minimal to ease maintenance.
  7. Error handling complete according to an articulated strategy.

Clean Code philosophy analogy

The Boy Scouts of America have a simple rule that we can apply to our profession.

Leave the campground cleaner than you found it.

If we all checked-in our code a little cleaner than when we checked it out, the code simply could not rot. The cleanup doesn’t have to be something big. Change one variable name for the better, break up one function that’s a little too large, eliminate one small bit of duplication, clean up one composite if statement.

Can you imagine working on a project where the code simply got better as time passed? Do you believe that any other option is professional? Indeed, isn’t continuous improvement an intrinsic part of professionalism?

The way to go ⭐

1. Names with meaning

About

Clean Code Summary with some personal comments.