Page 111 - 2502_Pakistan-kifayat_C-6
P. 111

WHAT IS DEBUGGING?


            Debugging  is the  process of finding  and  fixing  errors or problems
            (called bugs) in a computer program. When a program doesn’t work
            as expected—maybe  it  crashes, gives  wrong  results,  or behaves
            strangely—you debug  it to identify  what’s wrong and correct  the
            mistakes in the code.

            Debugging  helps  make programs  run smoothly and  correctly. It can
            involve  checking  your code carefully, testing parts step-by-step,  and
            using tools to spot errors.



            Debugging in Scratch


            Debugging in Scratch means finding and fixing mistakes or problems in your Scratch scripts that stop
            them from working correctly.
            When your sprite doesn’t do what you expect—like not moving, repeating forever, or not responding
            to clicks—you debug by:

                Checking your blocks step-by-step to find where the problem is.

                Using the “say” or “think” blocks to display messages that help you understand what’s happening.
                Testing small parts of your script one at a time.

                Looking for missing blocks, wrong connections, or incorrect conditions.


























            Ways to Debug a Scratch Program

            Here are some common ways to debug a Scratch program:

            1.  Test Small Parts: Run small sections of your script separately to find where the problem happens.

            2.  Use “Say” or “Think” Blocks: Add these blocks to show messages on the screen that help you check
               if the program is reaching certain points.




                                                                        #Fundamentals of Programming Constructs 109
   106   107   108   109   110   111   112   113   114   115   116