Week 1 DeBugIt

Summary of the Debug It  activity:

Debug each of the five Scratch programs in the Week 1 Debug It! studio.

    • Debug It! 1
      When the green flag is clicked, both Gobo and Scratch Cat should start dancing. But only Scratch Cat starts dancing! How do we fix the program?

    My solution:  This was an easy one.  I clicked on the sprite for gobo and it’s script did not have a ‘when green flag clicked’ block on top of the code so I added it.

    • Debug It! 2
      In this project, when the green flag is clicked, the Scratch Cat should start on the left side of the stage, say something about being on the left side, glide to the right side of the stage, and say something about being on the right side. It works the first time the green flag is clicked, but not again. How do we fix the program?

    My solution:   At the beginning of the script, right after the ‘when green flag clicked’ block,  I added a block to ‘go to x:-120, y:0’.  This will give him a starting position on the left.

    • Debug It! 3
      The Scratch Cat should do a flip when the space key is pressed. But when the space key is pressed, nothing happens! How do we fix the program?

    debugit1.3

    Iniitial code:  This one stumped me.  I tried it with and without the top block, I tried placing in a when green flag block, I even tried replacing the 4 blocks with 4 “point in direction __’ blocks. Then I tried it with only 3 blocks and the problem became apparent.  The code was working just fine– just too quickly for the eye to see.

Solution: Put one ‘Turn 90 degress’ block and a ‘wait 0.25’ seconds block in a ‘repeat 4’ block.

    • Debug It! 4
      In this project, the Scratch Cat should pace back and forth across the stage, when the Scratch Cat is clicked. But the Scratch Cat is flipping out — and is walking upside down! How do we fix the program?

    debugit4

Another simple fix.  Click on the little blue ‘i’ on Sprite 1 below the stage to open up sprite properties.  Change rotation style from the circle (360 degrees) to the <-> symbol.   It will now just turn left and right.

    • Debug It! 5
      In this project, when the green flag is clicked, the Scratch Cat should say ‘Meow, meow, meow!’ in a speech bubble and as a sound. But the speech bubble happens before the sound — and the Scratch Cat only makes one ‘Meow’ sound! How do we fix the program?

    debugit5

I rearranged the blocks from Say -> Repeat -> Play ->   to  Repeat [ -> Say-> Play]

Questions:

 What is one debugging strategy that you used?
     How would you help someone else learn how to debug a project?

I have difficulties answering because I just did it.  But my problem solving process seems to ask myself a series of questions:

  1. What is the code supposed to do?
  2. What does it actually do?
  3. Are there any obvious errors in spelling, order or logic?
  4. How can I fix the errors?
  5. How can I work around the errors?

Obviously it is more desirable to fix the problem, but sometimes a workaround will allow you to achieve the intended results (although it may not fix the underlying problem, and it may create more problems).

 

In answer to the second question, I would help someone debug a project by saying the above internal dialogue outloud, so that they can see that debugging is a process of asking questions and trying out different solutions.

Leave a Reply