Skip to content

Clean JavaScript: Clean Code, SOLID and Testing

Published:

Clean code is code that has been written with the intention that another person (or yourself in the future) understands it.

Responsibility

As software professionals, we have to be responsible for our developments. Whether it’s for a new functionality in a large company’s product, for a website we’ve been commissioned, helping a friend with their personal project, or if it’s a contribution to an Open Source project… it’s our responsibility to do it well.

We should develop in the best way we know how. There are many conventions, patterns and good practice guides. Knowing them and detecting how to apply them, and when not to apply them, is what will make us Software Craftspeople.

Clean JavaScript

Clean JavaScript

Let me recommend the book Clean JavaScript by Miguel A. Gómez. It’s a book that helps us improve the readability of our code, write more intuitive code that we can test easily and, most importantly, tolerant to change.

My Opinion

It’s a well-structured book, easy to read, with clear and concise examples according to the topic being discussed. All examples are available online so we can try them.

It consists of three sections:

  1. Clean Code: where it explains what it is, how to improve variable naming, functions, classes and comments.
  2. SOLID Principles: here it reviews each of the principles, with code examples. I liked that it starts by explaining why we should move away from STUPID principles.
  3. Testing and TDD: in the last section of the book, it talks about tests. It does so in a very pleasant way, with step-by-step examples, and even doing a kata with the TDD methodology.

Finding a book where you learn all these software development principles with examples in JavaScript is a real luxury. It has helped me internalize the concepts.

One of the things I love is that it’s full of references, which helps reinforce the message Miguel is giving and opens the door for us to investigate more on the topic.

You can tell he has a preference for TypeScript, but the examples he uses are very intuitive.

He closes the book with the recommendation of a book by a great friend and colleague, Agile Design with TDD by Carlos Blé. Which I have ready for reading 😊.


Previous Post
Agile Design with TDD
Next Post
CSS Animations