Washing your code
Washing your code
Minimum price
Suggested price
Washing your code

This book is 30% complete

Last updated on 2019-05-16

About the Book

The purpose of this book is to show common code smells or patterns that often (but not always!) lead to poor code readability, and how you can refactor the code to make it more readable and maintainable. The book contains a lot of code examples, most of which are based on real code with only minor adaptations.

Who is this book for

The book probably will be most useful for intermediate developers. If you’re a beginner, you probably have enough of other things to think about. If you have decades of experience, you probably can write a similar book yourself. This book is going to be opinionated, but you don’t have to agree with everything I’m saying, and that’s not the goal of the book. The goal is to show you one possible path, mine, and inspire to find your own. These techniques help me to write and review code every day, and I’ll be happy if you find some of them useful.

What you will learn

I'll show code smells and patterns I often see during code reviews (and I review a of code every day!) and will walk you through refactoring process to make code more readable and maintainable. I'll also show when you shouldn't follow my recommendations and keep using smelly code.

I'll show you how to:

  • Replace loops with array methods
  • Replace conditions with tables or remove them entirely
  • Replace imperative code with declarative and separate “what” and “how”
  • And more

About the Author

Artem Sapegin
Artem Sapegin

Frontend developer living in Berlin, award-losing photographer and owner of two crazy dogs. Creator of React Styleguidist.

Table of Contents

  • Washing your code: write once, read seven times
    • Preface
    • Acknowledgments
    • Avoid loops
    • Avoid conditions
    • Avoid reassigning variables
    • Avoid mutation
    • Avoid comments
    • Simplify, simplify, simplify
    • Naming is hard
    • Don’t surprise me
    • Separate “what” and “how”
    • Don’t waste energy (= save energy for important things)
    • Cargo cult programming
    • Don’t be clever
    • Divide and conquer, or merge and relax
    • Don’t make me think
    • Too many conventions
    • Make impossible states impossible
    • (Boy) scout rule
    • Greppable code
    • Size isn’t important
    • Don’t try to predict the future
    • Refactoring is inevitable
    • Not invented here syndrome
    • Code is evil
    • Resources
    • Conclusion

The Leanpub 45-day 100% Happiness Guarantee

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

See full terms

Free Updates. Free App. 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), EPUB (for phones and tablets), MOBI (for Kindle) and in the free Leanpub App (for Mac, Windows, iOS and Android). 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

Authors, publishers and universities use Leanpub to publish amazing in-progress and completed books and courses, just like this one. You can use Leanpub to write, publish and sell your book or course as well! 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. It really is that easy.

Learn more about writing on Leanpub