Worked example · Design Technology · Year 8

Algorithm for a recipe

DCF: Data and computational thinking → Problem-solving and modelling

What this is

A secure Year 8 response to all four parts, including the finished flowchart. Show the flowchart after pupils have drawn their own — it is the answer, and they will copy it. The two things to look for when marking are the labelled Yes/No arrows and at least one arrow that goes back up the page.

Part A — inputs, processes, outputs

Inputs Processes Outputs
225 g self-raising flour
110 g cubed cold butter
85 g caster sugar
50 g currants
½ tsp mixed spice
1 beaten egg
Up to 2 tbsp milk — a conditional input, only used if the dough will not hold together
Heat, at a medium setting
Extra butter and sugar for greasing and dusting
Rub butter into flour
Stir in sugar, currants and spice
Add egg and mix to a firm dough
Add milk a spoonful at a time and re-mix
Roll out to 5 mm
Cut 6 cm rounds
Re-roll the offcuts and cut again
Grease and heat the bakestone
Cook the first side for 2 minutes
Look underneath and judge the colour
Turn over and cook the second side
Move to the rack and dust with sugar
12 to 14 cooked Welsh cakes, dusted with caster sugar, on a cooling rack

Also an output, even though you do not eat it: the information "the underside is golden brown", which is what the decision in the flowchart uses

The equipment is neither. It is a resource — a tool the process needs but does not consume or produce. The bowl is still a bowl at the end; the 225 g of flour is gone. An algorithm still has to list it, for two reasons. First, the steps are impossible without it: "cut out rounds" means nothing without a cutter. Second, the equipment fixes the numbers — it is the 6 cm cutter and the 5 mm thickness that make the yield 12 to 14 rather than some other number, and it is a bakestone rather than an oven, which is why the cakes are cooked in batches on two sides.

Evidences criterion 1: the three columns are sorted correctly, milk is identified as a conditional input, and the answer about equipment explains why it matters instead of just naming it.

Part B — the numbered algorithm

1. Wash hands. 2. Collect equipment: bowl, wooden spoon, rolling pin, 6 cm cutter, bakestone, fish slice, cooling rack, scales, timer. 3. Weigh 225 g self-raising flour into the bowl. 4. Add 110 g cold cubed butter. 5. Rub the butter into the flour with fingertips until the mixture looks like fine breadcrumbs with no lumps of butter left. 6. Stir in 85 g caster sugar, 50 g currants and 1/2 tsp mixed spice. 7. Pour in 1 beaten egg. 8. Mix to a firm dough. 9. IF the dough is crumbly and will not hold together: REPEAT: add 1 tablespoon of milk and mix again UNTIL the dough holds together OR 2 tablespoons have been used. 10. Dust the worktop with flour. 11. Roll the dough out to 5 mm thick. 12. Cut out rounds with the 6 cm cutter. 13. REPEAT steps 11 and 12 with the offcuts UNTIL the dough is used up. (Expect 12 to 14 rounds.) 14. Grease the bakestone lightly and heat it to a medium heat. 15. Place up to 4 rounds on the bakestone. 16. Cook for 2 minutes. 17. Lift the edge of one round and look underneath. 18. IF the underside is not golden brown: REPEAT: cook for 30 more seconds and look again UNTIL it is golden brown. 19. Turn the rounds over. 20. Cook the second side for 2 minutes. 21. Move the cooked cakes to the cooling rack. 22. Dust with caster sugar while they are still warm. 23. REPEAT steps 15 to 22 UNTIL all the rounds are cooked. 24. Turn off the heat. Leave the bakestone to cool before moving it. 25. STOP.

Criterion 2: one instruction per line, every amount and time lifted from the recipe, and the three repeats are written with the condition that ends them. Step 9 also carries a limit of 2 tablespoons, which is what stops the loop running forever.

Part C — the flowchart

START INPUT: 225 g flour, 110 g butter, 85 g sugar, 50 g currants, 1/2 tsp mixed spice, 1 beaten egg Rub the butter into the flour with fingertips until like breadcrumbs Stir in the sugar, the currants and the mixed spice Add the beaten egg and mix to a firm dough Has the dough come together? No Add 1 tbsp milk, mix (2 tbsp maximum) Yes Roll out to 5 mm and cut rounds with the 6 cm cutter Is all the dough used up? No Yes Grease the bakestone and heat it to a medium heat Cook up to 4 rounds on the first side for 2 minutes Is the underside golden brown? No Cook for 30 seconds more, then look again Yes Turn over, cook 2 minutes, cool on the rack, dust with sugar Are all the rounds cooked? No Yes OUTPUT: 12 to 14 Welsh cakes, cooked on both sides and dusted with caster sugar STOP

Reading the loops. There are three arrows that go back up the page. The milk loop re-tests the dough after each spoonful and gives up at two spoonfuls. The dough loop sends you back to roll the offcuts and cut again until there is nothing left. The batch loop sends you back to the bakestone until every round has been cooked. The colour check is the fourth decision point and it loops in place, adding 30 seconds at a time.

Criteria 3 and 4: terminators are rounded, the ingredients and the finished cakes are parallelograms, everything you do is a rectangle and every question is a diamond with both exits labelled. Three separate loops go back to an earlier step, and each one has a condition that ends it.

Part D — the two trick questions

Why the milk cannot be one process box. Because it is not one action, it is an action plus a test, repeated. "Add milk until the dough comes together" needs you to add a spoonful, mix, look, and then either stop or go round again — and a process box runs once and has no way of asking a question. So it has to be a process box with a decision after it and an arrow going back. It also needs a limit: the recipe says two tablespoons is as far as you go, because too much milk makes the dough sticky and the cakes tough. Without that limit the loop could keep adding milk forever, which in computing is an infinite loop and in cooking is a bowl of batter.

Why the colour check has to come after the cooking, not before. If the diamond came first, the very first test would happen the moment the raw dough hit the bakestone, so the answer would always be No, and the loop would then cook in 30-second chunks from cold and never do the 2 minutes the recipe asks for. Put the cooking first and the test second, and the 2 minutes always happens exactly once and the 30-second top-ups only happen if they are needed. In programming that is the difference between a loop that checks before it acts and one that acts before it checks — and here, only one of them makes an edible cake.

Criterion 5: it explains why a conditional repeat cannot collapse into a single process box, spots the infinite-loop risk and the recipe's own limit, and gets the order of the cook-then-check loop right for the right reason.

Why this response is secure