
TDD is Like Cooking: Why I Taste My Code as I Go
I have a passion for software development and cooking is one of my favorite hobby. At first, they seem different. One is digital, the other is delicious! But they actually follow the same philosophy. What is TDD/BDD anyway? Some people think Test/Behavior-Driven Development (TDD/BDD) means writing every test case before you write any code. That’s not true. It’s actually about a cycle: Red: Write a small test that fails. Green: Write just enough code to make it pass. Refactor: Clean up the code. Repeat: Start over from Step 1. Here is how that looks in my kitchen: 1. The "Taste Profile" (BDD) Before I start, I decide what the dish should be. The Goal: "A spicy tomato soup with a hint of garlic." The Initial State: Right now, I just have a pot of plain water. The Result: If I taste it now, it fails. It’s not spicy, garlicky or even soup yet! This is my "failing case" that guides me. 2. Add and Test (TDD) I don’t throw all the spices or salt in at once. I go step-by-step: Step 1: I add ch
Continue reading on Dev.to
Opens in a new tab




