Cake Baking¶
Read time: 21 minutes (5313 words)
What’s that you say, this is a programming course? Well sure it is. But we need to begin at the beginning – with a problem or task to work on.
We also need be able to analyze that problem or task in enough detail to be able to tell the computer exactly what we want it to do for us. So, let’s consider a simple problem - baking a cake, actually, let’s bake two cakes!
Is this silly? Maybe so - but maybe not!
The problem statement¶
We are going to start detailing the process of baking two cakes. To make things a bit more interesting, assume that you are going to write up the instructions and hand them to someone who has no idea how to bake a cake! (Do such people exist? Who knows?)
Doing some research¶
Since we are all experts in the kitchen (HA!), we could just start writing down what we need to do, right? I do not know about you, but if I tried that I might get a cake, but it might be a brick instead. We could Google and find out what to do, but I chose to go to a real authority on the process. I scanned the back of a cake mix box in my pantry! With due credit to Duncan Hines, here is an image of the back of my cake box:

Breaking the problem down¶
As you look over this image, you should start to see several key things.
First, we have to collect a bunch of stuff (tools, ingredients, etc.) to do
the job. Next we have to manipulate those tools and ingredients in just the
right way to get a cake as a final output
result. (Is this just a weird IPO
chart?)
But wait, then we have to do the whole thing over again to get two cakes! Yikes!
The ingredients¶
At the top of the image we see that we are to collect the following ingredients:
1 and 1/3 Cups of water
1/3 Cup Vegetable Oil
3 large eggs
Oh yeah - I almost forgot!
A box of cake mix.
The tools¶
What else do we need to do the job?
Study the entire image and see what you can come up with. Here is my list.
An Oven (with temperature control)
A metal or glass or dark or coated cake pan (huh?)
Shortening (isn’t that an ingredient?)
Flour (another ingredient?)
Large bowl
Blender
Timer
Toothpick (!)
Wire rack
Frosting (another ingredient?)
That is a lot of stuff!
Is this list complete? Are there any problems with what we have written down yet?
Well, I did not remember that I have two cakes to bake, so I may need to modify this list a bit. What else needs to be modified?
All ingredients must be doubled since we consume them for each cake.
I might need additional tools to clean up the primary tools before I build the second cake.
The reason I am distinguishing between ingredients and tools is that I probably do not need two sets of tools, but I do need two sets of ingredients!
The sequence of steps¶
The image on the box has three steps. But we would see a few more if we look closely. Here is the sequence of actions we need to take to get the cake built!
Fire up the oven
If the cake pan is metal or glass, set the temperature to 350
If the cake pan is dark or coated, set the temperature to 325
Grease the pan sides and bottom with shortening
Flour the pan lightly
Pour cake mix into bowl
Pour water into bowl
Pour oil into bowl
Place eggs into bowl
Place bowl under blender
Start blender
Set blender speed to low
Set timer to 30 seconds
Start timer
Wait for timer alarm
Adjust blender speed to medium
Set timer to two minutes
Start timer
Wait for timer alarm
Stop blender
Pour mix from bowl into cake pan
Place cake pan into oven
Set timer according to cake pan size from chart
If cake pan is dark or coated increase timer time by 3-5 minutes
Wait for timer alarm
Remove cake pan from oven
Place pan on wire rack
Set timer for 15 minutes
Start timer
Wait for timer alarm
Frost cake
Oh phooey -
Do everything again (do we need to clean up first?)
Wow! Three simple steps on the cake mix box turned into 31 steps when we wrote down what we think is a complete list of things to do. A professional cook would blast through all of this without batting an eye.
Is this complete enough to work?¶
Once we think we know what we want to do, we need to step back and look things over. Maybe we can do a better job. Maybe we missed something. We need to make sure we are confident that our steps will really do the job!
Do you have any problems with what we have written down? I surely do!
Steps 1-3: Pretty hard to mess these up as long as you can tell what kind of pan you have.
Step 4: Hmmm! How much shortening do I need to use? About a half a pound should be right, right?
Step 5: Same problem here. How much flour do I need to use? A 5 pound bag should be about right!
Steps 6-8: Pretty clear here.
Step 9: I do not think just placing the eggs in the mix is right, do you?
Step 10: This one is fine
Steps 11-20: We are doing some time sensitive stuff here, this needs more study!
Steps 21-22: Nothing wrong here.
Steps 23-25: This is pretty complex. And I forgot a step, right?
Steps 28-30: More time sensitive stuff, but easier here.
Step 31: I need help here. What do I do to do this? (Google it?)
Help is on the way!¶
What would you do to all of this if you had a helper who could do part of the work for you? Can you see any part of the sequence above that you could carve off and hand over to to your new helper?
Here is a mantra I have heard some programmers mutter:
I am lazy! I do not want to do the same job twice! I will build a simple tool that someone else can use to do that job over and over! I will teach the computer to do that job, then I will relax!
We obviously have a way to go to finish this off. But this should get you thinking about how to approach a problem for now.