Debugging Movement Programming Events and Actions

 
Lesson 5: Debugging
movement
 
Programming – Events and actions in programs
 
Save a copy
 
Lesson 5: Debugging movement
 
Objectives
 
To identify and fix bugs in a program
I can test a program against a given design
I can match a piece of code to an outcome
I can modify a program using a design
 
2
 
Why do we need to debug?
 
3
 
Introduction
 
When have you made a program and found that it doesn’t work in the way
you would like?
Think, pair, share.
 
4
 
Activity 1
 
Go to this project: 
ncce.io/pg3b-5-a1-ca
 
Debugging a project
 
When the green flag is clicked, the
pencil should move to the centre, the
pen colour should be set to blue, and
all lines should be erased.
 
When green flag clicked — what’s the problem?
 
5
The pen is set to the wrong colour
A
B
C
The sprite does not move to the
centre
The lines are not erased
 
Activity 1
 
When green flag clicked — what’s the problem?
 
6
The pen is set to the wrong colour
A
B
C
The sprite does not move to the
centre
The lines are not erased
 
Activity 1
 
When the green flag is clicked, the
pencil should move to the centre, the
pen colour should be set to blue, and
all lines should be erased.
 
Add an 
erase all
 block.
 
When green flag clicked — how to fix it
 
7
 
Activity 1
 
When left arrow key pressed — what’s the problem?
 
8
The sprite moves down
A
B
C
The sprite moves right
The sprite does not move
 
Activity 1
 
When the left arrow key is pressed,
the sprite should point to the left and
move 10 steps.
 
When the left arrow key is pressed,
the sprite should point to the left and
move 10 steps.
 
When left arrow key pressed — what’s the problem?
 
9
The sprite moves down
A
B
C
The sprite moves right
The sprite does not move
 
Activity 1
 
What do you need to do?
Add a block?
Change a block?
Remove a block?
 
When left arrow key pressed — how to fix it
 
10
 
Activity 1
 
Change 
point in direction 90
to 
point in direction -90
 
When left arrow key pressed — how to fix it
 
11
 
Activity 1
 
When the up arrow key is pressed,
the sprite should point upwards and
move 10 steps.
 
When up arrow key pressed — what’s the problem?
 
12
The sprite moves down
A
B
C
The sprite moves right
The sprite does not move
 
Activity 1
 
Can you fix it in your project?
 
When up arrow key pressed — what’s the problem?
 
13
The sprite moves down
A
B
C
The sprite moves right
The sprite does not move
 
Activity 1
 
Write down the problem
Write down how to fix it
Fix it in the project
 
Now debug the other errors on your worksheet
 
14
 
Activity 1
 
There are four bugs in this program. Can you find them?
ncce.io/pg3b-5-a2-ca
 
Find the bugs
 
15
 
Activity 2
 
The sprite starts in the wrong place in the maze
The line drawn is too thick
There is no 
erase all
 block in the setup process, so the sprite draws a
line whenever it is moved, and the lines never disappear
The sprite has not been recentred, so the line is drawn from the middle of
the pencil, not the point
Can you fix the bugs?
 
Bugs in this project
 
16
 
Activity 2
 
Use the design below to modify the program.
1.
Start the pencil at x: -150, y: 150
2.
Clear all lines on the screen
3.
Centre the sprite on the tip of the pencil
4.
Select pen size 1, 2, 3, 4, or 5 by using those keys on the keyboard
Save your project.
 
Modifying a program using a design
 
17
 
Activity 3
 
Here are five steps to effective
debugging, but they are in the wrong
order.
Can you arrange them correctly?
 
 
Steps to effective debugging
 
18
 
Plenary
Identify the bug
Test the bug fix — does the code
now do what it should?
Fix the bug
Test the project
Review the task — what should the
project do?
1.
Review the task — what should
the project do?
2.
Test the project
3.
Identify the bug
4.
Fix the bug
5.
Test the bug fix — does the code
now do what it should?
 
Here are five steps to effective
debugging, but they are in the wrong
order.
Can you arrange them correctly?
 
 
Steps to effective debugging — answer
 
19
 
Plenary
 
20
 
Assessment
 
I can test a program against a
given design
I can match a piece of code to
an outcome
I can modify a program to
match a design
 
How confident are you? (1–3)
 
3 – Very confident
 
1 
 Not confident
 
2 
 Unsure
 
In this lesson, you...
Tested your program, debugged it
by correcting errors, and then
modified your design
 
 
Next lesson
 
21
 
Next lesson, you will…
Create, test, and debug your own
program to move a character around
a maze
 
Summary
Slide Note

Last updated: 01-07-20

This resource is available online at ncce.io/pg3b-5-s. Resources are updated regularly — please check that you are using the latest version.

This resource is licensed under the Open Government Licence, version 3. For more information on this licence, see ncce.io/ogl.

Embed
Share

Explore the process of debugging in programming, focusing on identifying and fixing bugs in a program. Learn how to test a program against a given design, match code to outcomes, and modify programs using existing designs. Engage in practical activities to improve your debugging skills.

  • Debugging
  • Programming
  • Events
  • Actions
  • Bugs

Uploaded on Jul 18, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Save a copy Lesson 5: Debugging movement Programming Events and actions in programs

  2. Objectives Lesson 5: Debugging movement To identify and fix bugs in a program I can test a program against a given design I can match a piece of code to an outcome I can modify a program using a design 2

  3. Introduction Why do we need to debug? When have you made a program and found that it doesn t work in the way you would like? Think, pair, share. 3

  4. Activity 1 Debugging a project Go to this project: ncce.io/pg3b-5-a1-ca 4

  5. Activity 1 When green flag clicked what s the problem? When the green flag is clicked, the pencil should move to the centre, the pen colour should be set to blue, and all lines should be erased. The sprite does not move to the centre A The lines are not erased B The pen is set to the wrong colour C 5

  6. Activity 1 When green flag clicked what s the problem? When the green flag is clicked, the pencil should move to the centre, the pen colour should be set to blue, and all lines should be erased. The sprite does not move to the centre A The lines are not erased B The pen is set to the wrong colour C 6

  7. Activity 1 When green flag clicked how to fix it Add an erase all block. 7

  8. Activity 1 When left arrow key pressed what s the problem? When the left arrow key is pressed, the sprite should point to the left and move 10 steps. The sprite moves right A The sprite does not move B The sprite moves down C 8

  9. Activity 1 When left arrow key pressed what s the problem? When the left arrow key is pressed, the sprite should point to the left and move 10 steps. The sprite moves right A The sprite does not move B The sprite moves down C 9

  10. Activity 1 When left arrow key pressed how to fix it What do you need to do? Add a block? Change a block? Remove a block? 10

  11. Activity 1 When left arrow key pressed how to fix it Change point in direction 90 to point in direction -90 11

  12. Activity 1 When up arrow key pressed what s the problem? When the up arrow key is pressed, the sprite should point upwards and move 10 steps. The sprite moves right A The sprite does not move B The sprite moves down C 12

  13. Activity 1 When up arrow key pressed what s the problem? Can you fix it in your project? The sprite moves right A The sprite does not move B The sprite moves down C 13

  14. Activity 1 Now debug the other errors on your worksheet Write down the problem Write down how to fix it Fix it in the project 14

  15. Activity 2 Find the bugs There are four bugs in this program. Can you find them? ncce.io/pg3b-5-a2-ca 15

  16. Activity 2 Bugs in this project The sprite starts in the wrong place in the maze The line drawn is too thick There is no erase all block in the setup process, so the sprite draws a line whenever it is moved, and the lines never disappear The sprite has not been recentred, so the line is drawn from the middle of the pencil, not the point Can you fix the bugs? 16

  17. Activity 3 Modifying a program using a design Use the design below to modify the program. 1. Start the pencil at x: -150, y: 150 2. Clear all lines on the screen 3. Centre the sprite on the tip of the pencil 4. Select pen size 1, 2, 3, 4, or 5 by using those keys on the keyboard Save your project. 17

  18. Plenary Steps to effective debugging Here are five steps to effective debugging, but they are in the wrong order. Identify the bug Test the bug fix does the code now do what it should? Can you arrange them correctly? Fix the bug Test the project Review the task what should the project do? 18

  19. Plenary Steps to effective debugging answer Here are five steps to effective debugging, but they are in the wrong order. 1. Review the task what should the project do? 2. Test the project Can you arrange them correctly? 3. Identify the bug 4. Fix the bug 5. Test the bug fix does the code now do what it should? 19

  20. Assessment How confident are you? (1 3) I can test a program against a 3 Very confident given design I can match a piece of code to 2 Unsure an outcome I can modify a program to match a design 1 Not confident 20

  21. Summary Next lesson In this lesson, you... Next lesson, you will Tested your program, debugged it by correcting errors, and then modified your design Create, test, and debug your own program to move a character around a maze 21

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#