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.