The podcast explores the necessity of the refactor step in Test Driven Development, including when to refactor and whether tests should be included. They discuss adding a 'done' feature to a command line application, the process of refactoring while writing tests, and the importance of writing first drafts and committing code frequently.
The refactor step in test-driven development (TDD) is important as it helps improve code quality and maintainability by making necessary changes and optimizations.
Debugging and fixing new tests first, limiting the scope to newly modified code, is a best practice for refactoring in TDD.
Deep dives
The Importance of Refactoring in Test-Driven Development
In this podcast episode, the speaker discusses the significance of refactoring in test-driven development (TDD). They address common questions related to the refactor step, such as whether it includes tests and if tests can be refactored at any time. The episode also highlights the benefits of doing the refactor at the end and provides examples to illustrate the TDD workflow.
Applying TDD to Add a New Feature in a Project
The podcast episode shares a story of applying TDD to add a new feature to a small command line interface-based team tracking application called Cards. The new feature involves adding a 'done' command to filter completed tasks. The speaker explains the TDD workflow followed, starting with writing tests for both the CLI and API, and then implementing the code changes. They discuss the challenges faced, including code duplication, and emphasize the importance of maintaining a focused scope for debugging and resolving failures.
Best Practices in TDD: Committing Code, Debugging, and Refactoring
The podcast episode offers insights into best practices for refactoring code in TDD. The speaker advocates for committing code before refactoring to have a working save point and the ability to revert if needed. They emphasize the importance of debugging and fixing new tests first, limiting the scope to newly modified code. The episode also touches upon the deviation from traditional TDD approaches, such as writing multiple tests at once and implementing both tests and code simultaneously, while still adhering to the core principles of TDD.