Using Heuristics to Cook
I like cooking. It’s one of my passions. I also like software testing. It too is a passion of mine. While cooking one night I noticed that I was using things that resembled heuristics I use in testing. I don’t usually use a recipe to cook – whatever is in the fridge will do. I just “go with it”. The results are usually pretty good. Some disasters have ensued – but not enough to make me follow a recipe. The creativity in doing this really gets me pumped. I experience some sort of flow or zone when putting ingredients together – taste a bit of this, add a bit of that, stir, taste again, repeat. While testing I experience similar feelings.
I use whatever I have at my finger tips. The recipe in testing can be known as requirements and like a cooking recipe I usually don’t follow too closely either (even if available). I do follow a similar process in testing though – try a function here, add some corrupt data there, click this again, repeat. Curious? Intrigued? Good – now help yourself to some home cooking.
One thing my fiancé and I cook on occasion is pasta. Have you ever cooked pasta? How do you know when it’s done? Ever thought it was done and when eating it found out it wasn’t? I definitely have. What a disappointment. You bite into some pasta and get a CRUNCH. It’s not very appetizing. What is the method you use to cook the pasta? Put water in a pot. Put pot on stove. Turn stove on. When water is boiling put some salt in (if you want), put pasta in pot and let cook. Sounds simple enough. But how long do you let it cook for?
I thought I had pasta cooking down to a science. How hard can it be? The instructions (on some packages) say what I mentioned above usually with one addition. Cook for 5 to 8 minutes or until ready. Does this direction sound ambiguous to you? Maybe vague and specific at the same time. If I followed the specification would I get “perfect pasta”? That’s how you should approach testing right? If it’s not documented then, as a tester, I don’t need think about it. Sometimes I want to believe that. As Jerry Weinberg said “It’s ok to want anything. Expecting it is a different issue.” You must know when to continue, even when requirements are unclear (especially when you are hungry!)
We hadn’t cooked pasta in about 8 months because we cut back on carbs. That rule got bent because we found a new sauce earlier in the day. It was tomato and marscoponi and looked really tasty sitting on the shelf. It’s light red colour initially caught my eye because I thought it was a red pepper spread and the size of the bottle didn’t fit with the bottles around it. Noticing things that stand out amongst others has a name that you might not have heard of – it’s called the Von Restorff effect (See notes for link). I use the Von Restorff effect in testing all the time. I frequently notice what doesn’t belong and it tends to be what I remember the most.
I showed the small bottle to my fiancé and we both got a craving for pasta. When we got home we were really excited. It was important that we get the pasta just right for the new sauce. To celebrate finding the sauce we also bought a new brand of pasta, imported directly from Italy. Like the sauce, the packaging and placement were also visually memorable. It had been a while since when we had cooked pasta so I decided to read the instructions. Here are the instructions as written on the package.
“The secret for a perfect pasta cooking, “al dente”. For every 100 grams of dry pasta you need about one liter of water (preferably not hard water). Boil the water slowly. Add about 10 grams of salt, pour in the pasta and turn up the stove, so that boiling is faster. Stir with a wooden utensil and let the pasta cook for the recommended time. When ready, add a cup of cold water and drain. Season to taste.”
One issue was we couldn’t find the recommended cooking time on the outside of the package, anywhere! Now what to do! The instructions aren’t clear. They want me to think! What!! This is cooking – it should be easy. I should just need to follow the instructions right?. And moreover it’s pasta – it can’t be that hard. My excitement dropped a little bit as I said this in my in my head. “Maybe I should try a different type of pasta that only requires 5 to 8 minutes exactly – no more, no less.” I quipped. “Well, I guess we aren’t having pasta tonight” – I laughed out loud. Even though the instructions were unclear – I decided to forge on. The fear of messing up the pasta quickly faded. This pasta will be just like every other type of pasta I’ve cooked.
We got talking about the instructions and the silliness of what I had just said.
“Seriously though – how do *you* know when pasta is done? I wonder if we use the same method.” I asked in an inquisitive way. This is a test technique I often use – questioning in an inquisitive. It’s especially effective with developers who are (often) like to keep information to themselves. I appeal to them to teach me something and share their knowledge with me. Sometimes I even come away with critical information for the project that until that point had only lived their head.
The wheels started turning in her head and she had to think about it for a few minutes. Often it is not easy to describe in words things we don’t normally put a lot of thought into. It’s even harder to do when those actions are open to interpretation. Humans are able to do it all the time though. It’s called heuristic problem solving.
“Well – one of the first things I do is look at it. If it’s become translucent I know it’s cooking.” she said.
“That’s cool. One of the first things I notice is how the pasta ‘feels’ on the spoon as I stir it. This gives me an indication of its ‘done-ness’. Also the type of spoon matters. Wood gives different feedback than metal.”
“Oh yeah – I notice that too!!” She said enthusiastically, “I also cut it with a fork. If it’s easy to cut then it’s probably a little overdone and time to serve it. If it’s hard to cut then it’s probably not cooked and needs more time.”
“That’s interesting. I usually skip right to tasting. I let a piece cool enough to taste. If it tastes good – great it’s done!! What does good mean? Not too hard or crunchy and not too soft and mushy. Let’s eat!!”
She asked “What about the touch or feel of it?”
“Yeah – when you pick it up you can feel if it is ready” I said, “Ever had this happen? After you strain the pasta you take another sample. Hmmm…that piece wasn’t quite done. Then you start thinking Uh-oh, are there any other pieces that aren’t cooked as well?”
“That’s never happened to me with pasta.” she replied.
“How about rice?”
“Oh my god – it happens so much with rice. I get really upset with rice.” Her mood changed a little bit.
“Don’t you follow the instructions” I asked jokingly.
The conversation ended with a good laugh. We really enjoyed the pasta that night. The sauce was excellent. The pasta was “done” to our liking. There was nothing we would have changed about the meal. It was perfect! All without clear instructions.
As a tester my work is often like cooking. I rely heavily on heuristics to tell me if I’m done. At times this has led me astray. I’ve stopped testing too early and also tested for longer than I should have. One thing I’m sure of is that if I didn’t use heuristics I would always get it wrong. Most of the time I able to find the sweet spot of enough but not too much. There’s nothing like a good heuristic to help you ship great software!
September 30th, 2007 at 10:56 PM
Good post – I’ve also compared testing to cooking in the past (with a slightly different take) and think the creativity involved in the two activities have a lot of similarities.
Cooking, like testing, is something you get better at with experience. It also helps to know specific techniques, have some expertise in with certain foods (or a breadth of knowledge), and have a willingness to experiment. Expert chefs discover a few fantastic food ideas purely by accident, but most of their signature dishes are created becaus they have an vast knowledge and encyclopedia of foods, herbs and spices, and can constantly come up with new ways to combine them.
Just like testing.
October 2nd, 2007 at 3:07 PM
This blog gives me some ideas on how to think about my automation (I know, I’m obessed about that topic right now).
I have a very sick cat right now who needs extra care, so this morning before I left I made up a crock pot of stew so that it will be ready when I come home so that instead of cooking dinner I can care for this cat. I did many things in advance to ensure that the food will be ready, edible, and clean up will be as efficient as possible.
One thing I did was I noticed they had these new “crock pot liners” at the store. I get very annoyed with scrubbing out the crockpot after eating dinner and letting it soak takes time, so I decided to try them. I’m not sure how well it will work, but I figured it was worth a try. It didn’t hurt that they were on sale.
If the cost of the automation were low enough and had a chance of solving a problem for me when I was at my busiest, I’d be willing to try it even without a guarantee that it would save me time. I’d be willing to risk a semi-ruined dinner or a pan which needed extra scrubbing.
The fact that I’ll leave a slow cooker on in my house without anyone there already shows I’m willing to take some risk. Maybe I could contain my automation risk to a crockpot rather than setting the entire house on fire.
By the way, enjoying cooking shows that you are artistic, where being a good baker shows you are more scientific. Those who can do both are unique. I know a few people who have talent in both areas, but to learn to bake well takes more learning in many cases.
I like to cook and rarely use recipes, measure anything, or follow rules, but if you apply those same principles to baking, disaster ensues. Cooking goes by feel more than baking does. I think bridging the gap from cooking to baking so that you can do both is needed to be a good tester who creates good test automation.