Test First Development and Making a Cake
One of the mixed curses of being obsessed with software is that you see reminders of it everywhere, even in things that predate the existence of software.
For example, Cake Making.
When you're making a cake, you need to add eggs to your cake mixture.
My wife told me that you don't break the eggs directly into the mixture. Instead, you break them into a separate bowl, and then add them to the mixture.
"Why not break them directly into the mixture?" I asked.
She picked up her cookbook and turned to Appendix A -- The SOLID Cooking Principles, by Robert C. Martin.
No she didn't.
She explained that if an egg is bad you don't want to ruin the entire bowl of cake mix. And it's easier to spot little bits of egg shell in a bowl of yolks than in a bowl of cake mix.
"Ah, the virtues of independent deployment," I said.
And she looked at me askance. (Askance is not the best way to be looked at, btw).
While we're discussing eggs, I have to repeat my favourite saw:
"You don't have to eat a whole egg to know it's bad."
(Side point: this topic fits with the stack overflow question "What real life bad habits has programming given you?" wherein you will find over 425 similar experiences. What a sad lot we is.)
Next → ← PreviousMy book "Choose Your First Product" is available now.
It gives you 4 easy steps to find and validate a humble product idea.
Matthew Martin on March 13, 2009 06:27 sez:
The other reason is that if there is any baking soda, the longer you can defer mixing wet with dry the less baking soda bubbles will be lost to mixing. Baking soda almost implements the same interface as yeast, but the abstraction is leaky.
Mike Woodhouse on March 13, 2009 06:32 sez:
Well, I dunno about all that. I think the egg business is more about running the tests as part of the build, which means of course that the tests could have been written before or after.
I think the TDD aspect, if applicable, is more about developing the recipe, which should be analogous to the code.
Depends if you see code as design or code as build, I guess.
I should get out more.
James on March 13, 2009 09:31 sez:
You gotta cook by the book. http://www.youtube.com/watch?v=UfLAv3JHRwY&feature=related
tarn on March 13, 2009 20:07 sez:
I just throw the eggs straight in. My cakes never work but I can make a great spaghetti bolognese.
Dominic Cronin on March 14, 2009 14:34 sez:
This is waterfall cake baking. The tradition of testing the eggs for freshness comes from the days when the eggs in question would have first sat on the desk of the analyst for a few weeks, before being assigned to a developer.
AtliB on March 14, 2009 18:58 sez:
Not sure if Mike above is hinting at it... but you could start with putting the eggs in (when the bowl is empty). Then you don't need to make two bowls dirty AND you can verify the eggs.
That might go against Matthews comments (and bakers in general) regarding baking soda bubbles, but that wasn't a part of the initial constraints of your example.
lb on March 14, 2009 19:03 sez:
@Atli
Although the initial constraints didn't include any mention of these baking soda bubbles, i think that in an agile cake making world we need to be able to take on board these late breaking changes to the user story.
All this micro-optimization of the cake making process makes me feel queasy.
I need to go and have a lie down. And maybe a nice cupcake.
Farmer Jeb on March 15, 2009 20:58 sez:
To quote my 2 year old son on this topic:
"CAKE! CAKE! CAKE! CAKE! CAKE!"