Skip to the page
Year 8 · Summer 2 · Raid: App Forge

Raid build: an app for a problem at school

What this lesson covers

Topic 14 Programming further

KS3 Computing · Real programs keep data in lists, take text apart as strings, split work into subroutines, check their input, save to files, and get tested on purpose.

Programming Computational ThinkingCambridge Lower Secondary Computing 0860

You will learn to

  • Use a stand-up to say what you did, what you will do next and what is blocking you.
  • Use a list in App Inventor to store many items under one name.
  • Create the must-have features in your brief one at a time, testing after each one.
  • Write a short log of what you built and what comes next.

Success criteria

  • I can give my stand-up in under a minute.
  • I can add an item to a list and show the whole list on the screen.
  • I can show one feature from our brief working on a phone.
  • I can write my log at the end of the lesson.

Key words

Say each word, then read what it means. Every one is in the glossary too.

List
One name holding many values in order. Also called an array.
Index
An item's position in a list, counting from 0.
Subroutine
A named block of code you can call when needed.
Function
A subroutine that returns a value.
Parameter
A placeholder in a subroutine for a value passed in.
Validation
Checking input is reasonable before using it.
Boundary data
Test data at the very edge of what's allowed.

The explanation

Read it here, or open the study page below to go one step at a time with things to try.

The stand-up

A stand-up is a very short team meeting at the start of the lesson. Everyone stands, so it stays short.

Each person answers three questions:

  1. What did I do last lesson?
  2. What will I do today?
  3. Is anything blocking me?

A blocker is a problem that stops you, like a missing picture or a bug you cannot fix.

e.g.Example

'Last lesson I built the screen. Today I will make the Add button work. Blocker: I don't know how to store more than one task.'

★Remember

One minute each. Solve problems after the stand-up, not during it.

Lists in App Inventor

A list stores many items under one name, in order. You met lists in Scratch in Year 7.

BlockWhat it does
initialize global tasks to (create empty list)Makes an empty list called tasks
add items to listAdds an item to the end of a list
select list itemGets the item at an index, like 1
remove list itemTakes out the item at an index
length of listSays how many items the list holds

An index is an item's place number in the list.

★Remember

App Inventor counts list items from 1, like Scratch. Python counts from 0.

A ListView component shows a whole list on the screen, one item per line.

Worked example: the homework list

The screen has a text box (txtTask), a button (btnAdd) and a ListView (lvTasks).

initialize global tasks to (create empty list)

when btnAdd.Click
    add items to list  list: (get global tasks)  item: (txtTask.Text)
    set lvTasks.Elements to (get global tasks)
    set txtTask.Text to ("")
  1. The list starts empty when the app opens.
  2. The user types a task and presses Add.
  3. The text in the box goes onto the end of the list.
  4. The ListView shows the whole list again, with the new task.
  5. The text box is cleared, ready for the next task.
e.g.Example

Stretch: add a task only if the box is not empty. Use an if with not and the is empty text block.

!Watch out

Variables vanish when the app closes. To keep the list, save it with a TinyDB component. TinyDB stores data on the phone.

Build, test, log

  1. Pick one must-have feature from your brief.
  2. Build only that feature.
  3. Test it on the phone.
  4. It works? Save a checkpoint, then pick the next feature.
  5. At the end of the lesson, write your log.
★Remember

Projects → Checkpoint saves a copy that works. If a change breaks the app, open the checkpoint.

e.g.Example

Log: 'Lesson 4: the Add button puts tasks in the list and shows them. Problem: empty tasks were added. Fixed with an is-empty check. Next: tick tasks off.'

e.g.Worked example

The list tasks holds: 'Maths p.12', 'Science poster', 'French words'. What does select list item with index 2 give? What is the list after remove list item with index 1?

  1. App Inventor counts from 1. Item 1 is 'Maths p.12'. Item 2 is 'Science poster'.
  2. So index 2 gives 'Science poster'.
  3. Removing index 1 takes out 'Maths p.12'.
  4. The list is now 'Science poster', 'French words'. Each item moves up one place.
  5. In Python the list starts at index 0. So index 2 would give 'French words'.

Study it

Open the study page and go one step at a time.

Check yourself

One question at a time. The reason shows after each answer.

Saved on this device.