Learning Test-Driven Development: A Polyglot Guide to Writing Uncluttered Code

This document was uploaded by one of our users. The uploader already confirmed that they had the permission to publish it. If you are author/publisher or own the copyright of this documents, please report to us by using this DMCA report form.

Simply click on the Download Book button.

Yes, Book downloads on Ebookily are 100% Free.

Sometimes the book is free on Amazon As well, so go ahead and hit "Search on Amazon"

Your code is a testament to your skills as a developer. No matter what language you use, code should be clean, elegant, and uncluttered. By using test-driven development (TDD), you'll write code that's easy to understand, retains its elegance, and works for months, even years, to come. With this indispensable guide, you'll learn how to use TDD with three different languages: Go, JavaScript, and Python. Author Saleem Siddiqui shows you how to tackle domain complexity using a unit test-driven approach. TDD partitions requirements into small, implementable features, enabling you to solve problems irrespective of the languages and frameworks you use. With Learning Test-Driven Development at your side, you'll learn how to incorporate TDD into your regular coding practice. This book helps you: • Use TDD's divide-and-conquer approach to tame domain complexity • Understand how TDD works across languages, testing frameworks, and domain concepts • Learn how TDD enables continuous integration • Support refactoring and redesign with TDD • Learn how to write a simple and effective unit test harness in JavaScript • Set up a continuous integration environment with the unit tests produced during TDD • Write clean, uncluttered code using TDD in Go, JavaScript, and Python

Author(s): Saleem Siddiqui
Edition: 1
Publisher: O'Reilly Media
Year: 2021

Language: English
Commentary: Vector PDF
Pages: 280
City: Sebastopol, CA
Tags: Python; JavaScript; Best Practices; Refactoring; Go; Continuous Integration; Testing; Test-Driven Development

Cover
Copyright
Table of Contents
Foreword
Preface
What Is Test-Driven Development?
A Technique
Designing and Structuring Code
A Bias Toward Simplicity
Increased Confidence
Who Is This Book For?
What Are the Prerequisites for Reading This Book?
How to Read This Book
Follow the Book One Language at a Time
Follow the Book in Two Languages First and Then in the Third Language
Follow the Book in All Three Languages Simultaneously
Conventions Used in This Book
Typographical Conventions
Lexical Conventions
Using Code Examples
How to Contact Us
TDD—The Whys
Why Does This Book Use Go, JavaScript, and Python?
Why Not This Other Language?
Why Does This Book Have a “Chapter 0”?
Chapter 0: Introduction and Setup
Setting Up Your Development Environment
Common Setup
Go
JavaScript
Python
Where We Are
Part I. Getting Started
Chapter 1. The Money Problem
Red-Green-Refactor: The Building Blocks of TDD
What’s the Problem?
Our First Failing Test
Go
JavaScript
Python
Going for Green
Go
JavaScript
Python
Cleaning Up
Go
JavaScript
Python
Committing Our Changes
Where We Are
Go
JavaScript
Python
Chapter 2. Multicurrency Money
Enter the Euro
Go
JavaScript
Python
Keeping Code DRY
Go
JavaScript
Python
Didn’t We Just Say “Don’t Repeat Yourself”?!
Divide and Conquer
Go
JavaScript
Python
Cleaning Up
Go
JavaScript
Python
Committing Our Changes
Where We Are
Chapter 3. Portfolio
Designing Our Next Test
Go
JavaScript
Python
Committing Our Changes
Where We Are
Part II. Modularization
Chapter 4. Separation of Concerns
Test and Production Code
Unidirectional Dependency
Dependency Injection
Packaging and Deployment
Modularization
Removing Redundancy
Where We Are
Chapter 5. Packages and Modules in Go
Separating Our Code into Packages
Go Modules
Creating a Package
Encapsulation
Removing Redundancy in Tests
Committing Our Changes
Where We Are
Chapter 6. Modules in JavaScript
Separating Our Code into Modules
A Segue into JavaScript Modules
CommonJS
Asynchronous Module Definition (AMD)
Universal Module Definition (UMD)
ESModules
Improving Our Tests
Removing Redundancy in Tests
Adding a Test Class and Test Methods
Discovering and Running Tests Automatically
Produce Output When Tests Run Successfully
Run All Tests Even When an Earlier Test Assertion Fails
Committing Our Changes
Where We Are
Chapter 7. Modules in Python
Separating Our Code into Modules
Removing Redundancy in Tests
Committing Our Changes
Where We Are
Part III. Features and Redesign
Chapter 8. Evaluating a Portfolio
Mixing Money
Go
JavaScript
Python
Committing Our Changes
Where We Are
Chapter 9. Currencies, Currencies, Everywhere
Making a Hash(map) of Things
Go
JavaScript
Python
Committing Our Changes
Where We Are
Chapter 10. Error Handling
Error Wish List
Go
JavaScript
Python
Committing Our Changes
Where We Are
Chapter 11. Banking on Redesign
Dependency Injection
Putting It All Together
Go
JavaScript
Python
Committing Our Changes
Where We Are
Part IV. Finishing Up
Chapter 12. Test Order
Changing Exchange Rates
Go
JavaScript
Python
Committing Our Changes
Where We Are
Chapter 13. Continuous Integration
Core Concepts
Version Control
Build Server and Agent
Artifact Repository
Deployment Environment
Putting It All Together
Create Your GitHub Account
Verify Your GitHub Account
Push Code Repository to GitHub
Prepare for CI Build Scripts
Go
JavaScript
Python
Committing Our Changes
Where We Are
Chapter 14. Retrospective
Profile
Cyclomatic Complexity
Coupling
Succinctness
Purpose
Cohesion
Completeness
Process
Putting It All Together
Go
JavaScript
Python
Isn’t TDD Dead?
Where We Are
Appendix A. Development Environment Setup
Online REPLs
Repl.it
LeetCode
CoderPad
The Go Playground
The Comprehensive List of Online REPLs
Integrated Development Environments (IDEs)
Visual Studio Code
IntelliJ IDEA
Eclipse
Installing Language Tools
Go
JavaScript / ES6
Python
Appendix B. A Brief History of the Three Languages
Go
JavaScript
The assert Module
The Module Mechanism
Python
Appendix C. Acknowledgments
Index
About the Author
Colophon