Washing your code
$15.00
Minimum price
$20.00
Suggested price

Washing your code

A book on clean code for frontend developers

About the Book

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 a lot 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 examples in the book are written in JavaScript with a bit of TypeScript, React, CSS, and HTML.

  • Share this book

  • Categories

    • Computers and Programming
    • Software Engineering
    • JavaScript
  • Feedback

    Email the Author(s)
  • License

About the Author

Artem Sapegin
Artem Sapegin

Coffee first frontend engineer living in Berlin, award-losing photographer, and friend of dogs. Creator of React Styleguidist.

Table of Contents

    • Preface
    • How to read this book
    • Acknowledgments
    • Avoid loops
      • Replacing loops with array methods
      • Implied semantics of array methods
      • Chaining multiple operations
      • Dealing with side effects
      • Iterating over objects
      • Sometimes loops aren’t so bad
      • But aren’t array methods slow?
    • Avoid conditions
      • Unnecessary conditions
      • Processing arrays
      • Deduplicating an algorithm
      • Optional function parameters
      • Early return
      • Repeated conditions
      • Tables or maps
      • Formulas
      • Nested ternaries
    • Avoid reassigning variables
      • Don’t reuse variables
      • Incremental computations
      • Building complex objects
      • Avoid Pascal style variables
      • Avoid temporary variables for function return values
      • Indeterminate loops
      • Help the brain with conventions
    • Avoid mutation
      • Avoid mutating operations
      • Beware of the mutating array methods
      • Avoid mutation of function parameters
      • Make mutations explicit if they are necessary
      • Updating objects
      • Even mutation is not so bad sometimes
    • Avoid comments
      • Getting rid of comments (or not)
      • Good comments
      • Bad comments
    • Naming is hard
      • Negative booleans are not not hard to read
      • The larger the scope, the longer the name
      • The shorter the scope the better
      • Making magic numbers less magic
      • Not all numbers are magic
      • Group related constants
      • Abbreviations and acronyms
      • Prefixes and suffixes
      • Dealing with updates
      • Beware of incorrect names
      • Beware of abstract and imprecise names
      • Use common terms
      • Use a single term for each concept
      • Use common opposite pairs
      • Check the spelling of your names
      • Use destructuring
      • Avoid unnecessary variables
      • Tips to avoid name clashes
    • Divide and conquer, or merge and relax
      • Let abstractions grow
      • Separate code that changes often
      • Keep together code that changes together
      • Sweep that ugly code under the rug
      • Bless the inline refactoring!
      • Separate “what” and “how”
      • Stay hydrated
    • Don’t make me think
      • Dark patterns of JavaScript
      • Gray areas
      • Make differences in code obvious
      • Write parallel code
      • Name things
    • Code style
      • Not all code styles are good
      • Obsolete code styles
      • Nonsensical code styles
      • Improving readability
      • Christmas trees vs. sausages
      • Make it easy to remember and use
      • To semicolon or not
      • Tabs or spaces
      • The rest doesn’t matter
      • Conclusion
    • Other techniques and issues
      • Make impossible states impossible
      • Don’t try to predict the future
      • Become a code scout
      • Make the code greppable
      • Avoid not invented here syndrome
      • Avoid cargo cult programming
      • Lint your code
      • Autoformat your code
      • Typecheck your code
      • Learn your code editor
    • Conclusion
    • Resources
      • Books
      • Articles
      • Talks
      • Please review the book
      • Got feedback?
      • Found an issue?

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

80% Royalties. Earn $16 on a $20 book.

We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $13 millionwriting, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub