Clean JavaScript. English Edition
Minimum price
Suggested price

Clean JavaScript. English Edition

A concise guide to learning Clean Code, SOLID and Unit Testing

About the Book

JavaScript is now  one of the most popular programming languages in the world. It is used in the critical infrastructures of many very important companies like Facebook, Netflix or Uber.

This is why writing better, higher quality and clearly legible code has become essential.  Normally, developers write code without the explicit intention of making it easily understood by  other people because we are focused on finding a solution that works and solves the problem without thinking about people. Usually, trying to understand the code written by other programmers or even code that we wrote ourselves a few weeks ago, can be quite difficult. 

This small e-book strives  to be a concise reference of how to apply clean code, SOLID, unit testing and TDD, to be able to write more legible, maintainable  and change tolerant JavaScript code. In this book you will find several references to other authors and simple examples that will help you to find the way to become a better developer.

  • Share this book

  • Categories

    • JavaScript
    • TypeScript
    • Computers and Programming
  • Feedback

    Email the Author(s)

This book is a translation into English of Clean JavaScript which was originally written in Spanish.

About the Author

Software Crafters
Software Crafters

Software Crafters es una web sobre artesanía del software, DevOps y tecnologías software con aspiraciones a plataforma de formación y consultoría.

En Software Crafters nos alejamos de dogmatismos y entendemos la artesanía del software, o software craftsmanship, como un mindset en el que, como desarrolladores y apasionados de nuestro trabajo, tratamos de generar el máximo valor, mostrando la mejor versión de uno mismo a través del aprendizaje continuo.

En otras palabras, interpretamos la artesanía de software como un largo camino hacia la maestría, en el que debemos buscar constantemente la perfección, siendo a la vez conscientes de que esta es inalcanzable.

Table of Contents

  • Preface
    • What this book is not.
  • About the author
  • Introduction
  • Technical Debt
    • Kinds of technical debt
    • Refactoring, debts are paid
    • Prevention is better than cure, the rules of simple design
  • Section I: Clean Code
  • What is Clean Code?
  • Variables, names and scope
    • Correct use of var, let y const
    • Pronounceable and expressive names
    • Absence of technical information in the names
    • Establish a ubiquitous language
    • Names by data type
    • Numbers
    • Scope of the variables
  • Functions
    • Function declaration
    • Function Expression
    • Function expression with the arrow function
    • Immediately-invoked Function Expressions (IIFE)
    • Parameters and arguments
    • Indentation size and levels
    • Declarative vs imperative style
    • Anonymous functions
    • Referential transparency
    • DRY Principle
    • Command–Query Separation (CQS)
    • Efficient algorithms
  • Classes
    • Prototype and modern ECMAScript
    • Reduced size
    • Organization
    • Prioritize composition over inheritance
  • Comments and format
    • Avoid using comments
    • Consistent format
  • Section II: SOLID Principles
  • Introduction to SOLID
  • From STUPID to SOLID
    • What is code smell?
    • Singleton pattern
    • Tight Coupling
    • Premature optimization
    • Indescriptive Naming
    • Duplication
  • SOLID principles to the rescue
  • Single responsibility principle (SRP)
    • What do we understand by responsibility?
    • Applying the SRP
    • Detecting violations of SRP
  • OCP - Open/Closed principle
    • Applying OCP
    • Adapter pattern
    • Detect violations of OCP
  • LSP - Liskov Substitution Principle
    • Applying LSP
    • Detect violations of LSP
  • ISP - Interface segregation principle
    • Applying the ISP
    • Detect violation of ISP
  • DIP - Dependency Inversion Principle
    • High-level modules and low-level modules
    • Depending on Abstractions
    • Dependency Injection
    • Applying DIP
    • Detecting violations of DIP
  • Section III: Testing & TDD
  • Introduction to testing
  • Types of software tests
    • What do we understand by testing?
    • Manual tests vs automatic tests
    • Functional vs non-functional tests
    • Non-functional tests
    • The Pyramid of testing
    • Ice Cream cone anti-pattern
  • Unit testing
    • Characteristics of the unit tests
    • Anatomy of a unit test
  • Jest, the definitive JavaScript testing framework
    • Features
    • Installation and configuration
    • Our first test
    • Asserts
    • Organisation and structure
    • State management: before and after
    • Code coverage
  • TDD - Test Driven Development
    • The three laws of TDD
    • Red-Green-Refactor cycle
    • TDD as a design tool
    • Implementation strategies, from red to green
    • TDD Limitations
  • Practical TDD: The FizzBuzz Kata
    • The code katas
    • The Fizzbuzz kata
    • Exercise statement
    • Designing the first test
    • We run and… red!
    • We go green
    • Adding new tests
    • Refactoring the solution, applying pattern matching.
  • References

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