A concise guide to learning Clean Code, SOLID and Unit Testing
About the Book
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.
- What this book is not.
- About the author
- 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
- Scope of the variables
- 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
- Prototype and modern ECMAScript
- Reduced size
- 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
- 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
- Characteristics of the unit tests
- Anatomy of a unit test
- Installation and configuration
- Our first test
- 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.
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.
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 $12 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.