Thursday, May 10, 2012

The Importance of Design in Five Course Meals


For any moderately complex program or algorithm, it often helps to design the solution before work begins. Good design practices can save a significant amount of time, help avoid wasting effort, and prevent mistakes.

"I can fix this," Chef Pepperton said to himself as he rummaged through a box of fresh vegetables.  "I just need some radishes."

Behind him, the kitchen was in chaos.  The other cooks dashed about, trying to prepare the remainder of a five course meal.  The soup had just been carried out, and the other four courses were far from ready.  In fact, they were not exactly decided yet.

"Radishes?!?" screamed Chef Pepperton.  "Do we have any radishes?"

One of the other chefs paused for a moment in thought.  "No," he said.

Pepperton turned back to the box.  "I can fix this," he mumbled. "Carrots.  I can do it with carrots."

Then he loudly announced, "We are changing the menu to carrot ravioli.  CARROT RAVIOLI."

In the back corner of the kitchen the dessert chef groaned.  Since Chef Pepperton had now claimed the carrots, the dessert chef scratched his plans for carrot cake and started working on a chocolate pudding.  He hated when Pepperton changed his mind halfway through a meal.

"How is the appetizer coming?" Pepperton asked.

"A little burnt, but we can peel off the worst bits," answered his assistant.

Pepperton looked at the stove top.  Three pots and two pans occupied the stove's five burners.  Delicious aromas crept from two of the pots and a beautiful sauce simmered in one of the pans.  In the other pan, the cooked tomatoes for the appetizer sent up curly wisps of black smoke.  The final pot contained boiling water, but Pepperton could no longer remember what he had meant to boil.

Pepperton cursed under his breadth.  He thought for a moment, surveying the countertop for inspiration.  Then he replied, "Add some lime juice and call it something festive."

An hour ago he had felt a lot better about this meal -- confident even.  "I can whip up a five course meal for his majesty," he had boasted.  "I'm sure we have everything we need in the kitchen."

"If we do ravioli, we need another burner," noted his assistant. "Something else will have to come off."

Pepperton looked at the stove.  He counted the burners to confirm the problem.  Even if they took off the now charring tomatoes, they were one burner short.  He racked his brain and scanned the kitchen.  He again saw the mysterious pot of boiling water.

"Forget the mashed potatoes," he said, his memory kicking in. "Throw the potatoes in the fire for two minutes and call them charred potatoes.  Say they go with the tomatoes.  We'll use the boiling water for the ravioli."

"I need the fire for the salad," protested the assistant.

"Make it a cold salad," ordered Pepperton.  "And where is the salt?"

"Over here," called the dessert chef.

Pepperton dashed over to retrieve the salt.  "Curse the king's surprise visit," he thought.  Then he quickly amended his internal commentary to include a statement on how nice it was that the king had chosen this dining establishment. You could never be too careful.

"And the radishes?" asked Pepperton.

"You switched to carrots," reminded the assistant.

"Hold on a second," said Pepperton. "I think I might need to write this down."

An unnatural hush fell through the kitchen. It was worse than if someone had screamed it out loud.  Pepperton knew what everyone was thinking.  He could hear his own boastful words echo through his head, "We don't need any planning. We've done this a hundred times. We'll just put something together."  He shook his head to clear away the doubts and tried to concentrate on saving the meal.

He was halfway through finally writing down a menu when his assistant interrupted him. "Chef, your carrots are burning."

Pepperton groaned and crossed "Carrot Ravioli" off his menu.

--------------------------

Want to read more about programming and kitchens?  See Variable Initialization in Busy Kitchens or Computer Memory and Making Dinner.

Book update: The second draft of the book is complete.  It includes 30 revised stories and 15 new stories.  Story list coming soon.