Uncertain Requirements and Prototypes
What you'll learn: How to balance TDD's structured approach with the exploratory nature of prototyping when requirements are unclear or rapidly evolving.
The Challenge of TDD During Exploration
TDD assumes you understand what you're building well enough to write a failing test. But in early product exploration—when you're trying to understand user needs, test market assumptions, or experiment with technical approaches—requirements shift constantly. Writing comprehensive tests for code you'll likely throw away feels wasteful.
When to Loosen TDD's Grip
Think of prototyping like sketching before painting. You wouldn't frame and varnish a rough sketch—similarly, strict TDD might slow you down when you need to learn quickly through experimentation.
During prototyping phases:
- Write throwaway code explicitly marked as experimental
- Skip tests temporarily to maximize learning speed
- Focus on answering specific questions: "Will users understand this flow?" or "Can this API handle our data model?"
- Set a time limit for exploration before deciding what to keep
Transitioning Back to TDD
Once you've learned from the prototype:
- Identify keeper patterns: What insights did you gain?
- Discard the prototype code: Resist the urge to "clean it up"
- Start fresh with TDD: Now that you know what you're building, write tests first for the real implementation
- Extract reusable learnings: Did you discover edge cases or constraints? Turn those into tests.
The prototype's value was in what you learned, not the code itself.
Key Takeaway: TDD excels when requirements are clear, but during uncertain exploration phases, prioritize learning over test coverage—then return to TDD discipline once you understand what you're actually building.