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.

Washing your code book cover

What’s inside?

  • PDF and EPUB formats
  • 20 years of experience packed into 350 pages
  • 3700 lines of unit-tested code examples
  • Based on production code
  • Up to date: ECMAScript 2024
  • No bullshit approach

Table of contents

  • Avoid loops

    Iterating over collections and why traditional loops like `for` and `while` may not be the best approach

  • Avoid conditions

    Writing good conditions and simplifying the code by removing unnecessary ones

  • Avoid reassigning variables

    Improving code readability by making it easier to understand what variables are doing and how they are used in the code

  • Avoid mutation

    Why mutation is hindering code readability and what can we do about it

  • Avoid comments

    Writing useful comments, when to write them and when not

  • Naming is hard

    How clear names make it easier to understand the code, and how to improve naming in our apps

  • Divide and conquer, or merge and relax

    Splitting code into functions and modules, when is the right time to introduce an abstraction, and when it’s better to wait

  • Don’t make me think

    All the different ways programmers like to write clever code, and why we should avoid it as much as possible

  • Code style

    Which code styles are actually improving readability and which are just opinions that don’t matter much

  • Lint your code

    How linters can help us maintain consistent and modern codebase, and promote some of the techniques discussed in the previous chapters

  • Autoformat your code

    How tools can make our lives much easier by formatting code for us

  • Learn your code editor

    Different techniques for editing code and customizing our environment to make our work more efficient and less tiring

  • Other techniques

    Make impossible states impossible

    Don’t try to predict the future

    Become a code scout

    Write testable code

    Write greppable code

    Avoid not invented here syndrome

    Avoid cargo cult programming

    Debug code with emojis

    Go for a walk or talk to a rubber duck

What readers are saying?

I’ve been following the author’s blog for quite some time to grab an advice or to catch up on best engineering practices. I was excited to find out there’s a whole dedicated book he was working on 🙌 I’m into several chapters now and already got enlightened on some topics I thought I knew well 🙂 I really like a mix of theory and clear practical examples that are up to a point. It’s never a dry reading so can highly recommend it 👍

Nick PlekhanovSenior Fullstack Engineer

Artem skillfully highlights common code smells and anti-patterns that I also frequently encounter when reviewing code. Each chapter offers actionable insights on refactoring and improving code readability, which are critical whether you’re just starting out or are a longtime developer looking to polish your skills. I already “felt” the lessons but hadn't really internalized them. Reading them from someone else sort of fixed them in my understanding of code and how to work with it.

Troy GiuniperoSenior Frontend Developer

Frequently asked questions

Is the book complete?

Almost! I’m planning to finish the book by the end of summer 2024.

Will the book be updated over time?

Yes, I’m planning to keep the book as a living snapshot of my programming knowledge, and also update the example with the latest JavaScript features. Subscribe to my newsletter to know about major updates.

Do I need to know JavaScript?

Not necessarily, though it will certainly help. However, even if you’re working with other languages, you could still find the book useful.

Is the book available to buy on Amazon?

Not yet, but I’m planning to publish the book on Amazon as soon I finish writing the book.

Is the book available on paper?

Not yet, but I’m planning to publish the dead tree version as soon I finish writing the book.

Can I buy multiple copies for my team at a reduced price?

Yes, write me at artem@sapegin.ru.

Do you offer purchasing power parity or student discounts?

Write me at artem@sapegin.ru, and we’ll think of something.

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, Stage+, 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.