Initial commit: TDD Workshop exercises for participants
- Password Validator kata with starter code and tests - Shopping Cart kata with starter code and tests - FizzBuzz reference code (from live demo) - Setup guide and TDD reference card - No solutions included (participants implement themselves)
This commit is contained in:
commit
3d94c96ed2
13 changed files with 1469 additions and 0 deletions
200
README.md
Normal file
200
README.md
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
# TDD Workshop - Exercises
|
||||
|
||||
**A hands-on, 2-hour workshop for learning Test-Driven Development through deliberate practice.**
|
||||
|
||||
This repository contains the exercise materials for the TDD workshop. Follow the setup guide to prepare before the workshop.
|
||||
|
||||
---
|
||||
|
||||
## Before the Workshop
|
||||
|
||||
### 1. Complete Setup
|
||||
|
||||
Follow the **[SETUP_GUIDE.md](SETUP_GUIDE.md)** to:
|
||||
- Install Dart SDK
|
||||
- Verify your development environment
|
||||
- Run a test to confirm everything works
|
||||
|
||||
### 2. Verify Installation
|
||||
|
||||
Test that everything is working:
|
||||
|
||||
```bash
|
||||
cd password_validator
|
||||
dart pub get
|
||||
dart test # Should see "All tests skipped" or similar
|
||||
```
|
||||
|
||||
### 3. Bookmark Reference
|
||||
|
||||
Keep **[TDD_REFERENCE_CARD.md](TDD_REFERENCE_CARD.md)** handy during the workshop for quick reference on the RED-GREEN-REFACTOR cycle.
|
||||
|
||||
---
|
||||
|
||||
## Repository Structure
|
||||
|
||||
```
|
||||
tdd-workshop-exercises/
|
||||
├── README.md (you are here)
|
||||
├── SETUP_GUIDE.md # Setup instructions
|
||||
├── TDD_REFERENCE_CARD.md # Quick reference for TDD
|
||||
│
|
||||
├── fizzbuzz/ # Live demo kata (reference)
|
||||
│ ├── README.md
|
||||
│ ├── lib/fizzbuzz.dart
|
||||
│ └── test/fizzbuzz_test.dart
|
||||
│
|
||||
├── password_validator/ # Hands-on exercise (Option A)
|
||||
│ ├── README.md # Exercise instructions
|
||||
│ ├── lib/password_validator.dart # TODO: Implement here
|
||||
│ └── test/password_validator_test.dart # Uncomment tests step-by-step
|
||||
│
|
||||
└── shopping_cart/ # Hands-on exercise (Option B)
|
||||
├── README.md # Exercise instructions
|
||||
├── lib/shopping_cart.dart # TODO: Implement here
|
||||
└── test/shopping_cart_test.dart # Uncomment tests step-by-step
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## During the Workshop
|
||||
|
||||
### Part 1: Live Demo (15 min)
|
||||
|
||||
Watch the facilitator demonstrate the RED-GREEN-REFACTOR cycle with **FizzBuzz**.
|
||||
|
||||
The `fizzbuzz/` directory contains reference code you can review later.
|
||||
|
||||
### Part 2: Choose Your Kata (45 min)
|
||||
|
||||
Pick **one** kata to practice:
|
||||
|
||||
#### Option A: Password Validator
|
||||
- Build a password validator with 5 rules
|
||||
- Practice rule-based validation
|
||||
- Discover the Open-Closed Principle through refactoring
|
||||
|
||||
**Start here:** `password_validator/README.md`
|
||||
|
||||
#### Option B: Shopping Cart
|
||||
- Build a shopping cart with add, remove, discount
|
||||
- Practice stateful domain modeling
|
||||
- Discover when to use Map vs List
|
||||
- Learn the Value Object pattern
|
||||
|
||||
**Start here:** `shopping_cart/README.md`
|
||||
|
||||
### Part 3: Debrief & Reflection (10 min)
|
||||
|
||||
Share learnings and discuss design insights with the group.
|
||||
|
||||
---
|
||||
|
||||
## The TDD Workflow
|
||||
|
||||
For each kata, follow this rhythm:
|
||||
|
||||
```
|
||||
1. Uncomment the next test
|
||||
2. Run tests → watch it FAIL (RED)
|
||||
3. Write minimal code to make it pass (GREEN)
|
||||
4. Refactor if needed → tests stay GREEN
|
||||
5. Commit your work
|
||||
6. Repeat with the next test
|
||||
```
|
||||
|
||||
**Key principles:**
|
||||
- Write the test BEFORE the implementation
|
||||
- Take small steps (one test at a time)
|
||||
- Make it work first, make it clean second
|
||||
- Let the tests drive your design
|
||||
|
||||
---
|
||||
|
||||
## Running the Katas
|
||||
|
||||
### Password Validator
|
||||
```bash
|
||||
cd password_validator
|
||||
dart pub get
|
||||
dart test
|
||||
```
|
||||
|
||||
### Shopping Cart
|
||||
```bash
|
||||
cd shopping_cart
|
||||
dart pub get
|
||||
dart test
|
||||
```
|
||||
|
||||
### FizzBuzz (reference)
|
||||
```bash
|
||||
cd fizzbuzz
|
||||
dart pub get
|
||||
dart test
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
Having issues? See **[SETUP_GUIDE.md](SETUP_GUIDE.md)** for:
|
||||
- Dart installation problems
|
||||
- `dart pub get` failures
|
||||
- Test execution errors
|
||||
- IDE configuration
|
||||
|
||||
---
|
||||
|
||||
## After the Workshop
|
||||
|
||||
### Continue Practicing
|
||||
|
||||
Explore more katas at:
|
||||
- **TDD Katas Collection:** https://github.com/dhemasnurjaya/tdd-katas
|
||||
- **Kata-Log:** https://kata-log.rocks
|
||||
- **Exercism:** https://exercism.org
|
||||
- **Coding Dojo:** https://codingdojo.org
|
||||
|
||||
### Recommended Reading
|
||||
|
||||
- *Test-Driven Development* by Kent Beck
|
||||
- *Clean Code* by Robert C. Martin
|
||||
- *Growing Object-Oriented Software, Guided by Tests* by Freeman & Pryce
|
||||
|
||||
### Keep Practicing!
|
||||
|
||||
The **RED-GREEN-REFACTOR** cycle becomes second nature with practice:
|
||||
1. Start with small, obvious katas
|
||||
2. Practice the rhythm until it's automatic
|
||||
3. Gradually tackle more complex problems
|
||||
4. Focus on letting tests drive design decisions
|
||||
|
||||
---
|
||||
|
||||
## Questions?
|
||||
|
||||
During the workshop:
|
||||
- Raise your hand or ask your facilitator
|
||||
- Don't hesitate to ask for help if you're stuck!
|
||||
|
||||
Before the workshop:
|
||||
- Contact your workshop facilitator
|
||||
- Verify your setup using SETUP_GUIDE.md
|
||||
|
||||
---
|
||||
|
||||
## Philosophy
|
||||
|
||||
> "Clean code that works." — Ron Jeffries
|
||||
|
||||
TDD is a **discipline**, not a burden:
|
||||
- Tests first (even for "obvious" code)
|
||||
- Small steps (one test at a time)
|
||||
- Refactor fearlessly (tests protect you)
|
||||
|
||||
**The goal:** Build muscle memory for the RED-GREEN-REFACTOR cycle.
|
||||
|
||||
---
|
||||
|
||||
**Ready to practice? See [SETUP_GUIDE.md](SETUP_GUIDE.md) to get started!**
|
||||
Loading…
Add table
Add a link
Reference in a new issue