AdvertisementYour brand could be hereYour brand hereOn every Darslab page · students, parents and teachersinfo@darslab.comAsk for pricesPricesinfo@darslab.com
☰ Year plan · Computing

Test as you go

Week 25 · Unit 10: Be a storyteller · 3 lessons
1

Write a little, test a little

Computing 2: Unit 10, pp. 134–148
GoalSay why we test a program after each small part.
New words
test · to run a program to see if it workspart · a small piece of a bigger programerror · a mistake
Explanation

A big program is easier to make in small parts. Write one part. Then test it before you write the next part. If you find an error, you know it is in the part you just wrote. Errors are easier to fix early. Then there are fewer errors at the end.

write a parttest itfix errors
Worked examples
Hello!2
Ravi makes a story about a farmer. Part 1 is: start on green flag, say “Hello!”, move right 2, stop. He makes the blocks and taps the green flag. The farmer says “Hello!” and moves 2. Part 1 works.
Hello!3
Suppose Ravi typed 3 by mistake. When he tests part 1, the farmer moves 3 squares, not 2. He finds the wrong number at once, because he only wrote one part.
When we testWhere is the error?
after each partin the part we just wrote
only at the endcould be in any part
Two ways to build a program. Testing after each part is faster than testing only at the end.
Class activity

Build and check (pairs): one child writes an algorithm for part 1 of a short story, such as “start on tap, say Hello!, hop 2, stop”. The other child makes block cards for it on paper. Test by acting it out. Tick it, or fix it. Then write and test part 2. Did you find mistakes early?

Practice
1
Why is it better to test part 1 before you write part 2?
2
Part 1 should say “Hi!” and then move up 2. Test the blocks. What is wrong?
2Hi!
3
Put these in the best order: A test it, B write one part, C fix any error.
A: test itB: write one partC: fix any error
4
Nina wrote her whole program and tapped the green flag once, at the end. There were four errors. Why is this hard?