Washing your code

A book on clean code for frontend developers

About the book

We read code much more often than we write it — often to make a one-line change you have to read and understand hundreds of lines of code scattered among dozens of files. That’s why code readability is so important.

On dozens of examples, based on production code, I’ll show you how to make your code more readable and maintainable, and how to avoid hard-to-track bugs. I’ll show you code smells and antipatterns I often see during code reviews (and I review lots of code every day!) and will walk you through the refactoring process to make your code better.

These techniques help me every day to write code that my colleagues will have no problems working with. All book’s examples are written in JavaScript with a bit of TypeScript, React, CSS, and HTML.

Or read selected chapters below

Washing your code book cover

Table of contents

  • Preface
  • Acknowledgments
  • Avoid loops
  • Avoid conditions
  • Avoid reassigning variables
  • Avoid mutation
  • Avoid comments
  • Naming is hard
  • Code style
  • Constants
  • Separate “what” and “how”
  • Don’t be clever
  • Divide and conquer, or merge and relax
  • Don’t make me think
  • Make impossible states impossible
  • Don’t try to predict the future
  • Become a code scout
  • Make the code greppable
  • Cargo cult programming
  • Not invented here syndrome
  • Refactoring is inevitable
  • Code is evil
  • Tooling
  • Linters
  • Other tools
  • Resources
  • Conclusion
Artem Sapegin

About the author

Hola! I’m Artem.

I’m a software engineer with 20 years of experience in small startups and large corporations, like Wayfair, Mail.ru, Here Technologies, Omio, and Badoo, I created React Styleguidist (a tool to create React components and share them with your team), among many other open source projects.

I’ve been blogging about frontend development for almost as many years. My favorite topics are component-driven development, testing, and accessibility.

Have a question?

Drop me a line at artem@sapegin.ru, @sapegin@mastodon.cloud, @iamsapegin, or open an issue.