Unit 3

Debugging

Your program doesn't work as expected? Or doesn't work at all? Did you hit a wall and aren't sure how to solve the issue? It happens to the best of programmers. This unit focuses on debugging as well as strategies to get unstuck.

Debugging is crucial theme to explore when learning or teaching to code. There are so many steps to take when turning an idea into a working program - bugs or mistakes are often inevitable. Don't get discouraged. Instead, practice debugging.

Themes: Debugging and Strategies to get unstuck

What is Debugging?

Definition: Debugging is the process of detecting and removing errors (commonly called "bugs") in a computer code.

To debug a program or code, the programmer starts by identifying the problem, isolating the source and then fixing it. Debugging isn't always easy - even for the more experienced programmer. It's a problem solving skill that you develop with practice.

Did You Know...?

The term "debugging" actually originates from a real bug! Watch the video below about an inspiring, brilliant scientist and computer pioneer, admiral Grace Hopper, who discovered a mysterious computer bug in the Harvard Mark II computer. (Did you know that America's first computer, the Harvard Mark I, measured 51 feet long, 8 feet high and 8 feet wide!)

Strategies & Questions to Ask Yourself

Ask yourself...
-How do YOU fix something that isn't working?
-Do you follow specific steps?
-
Debugging is like solving a puzzle... Did you use incorrect loops? Are there missing blocks? Are there extra blocks? Are the blocks in the correct order? Etc.

Strategies...
-Look at what your code is doing, step by step. Compare it with what it should be doing.
-Translate each code block into words or sentences.
-If you have several blocks of code or sections, break them down into small chunks.
-Ask a friend to take a look at your code.

Practice...
-When you have a working program, play with some of the variables to see how they influence your program. The
RBG LED Challenge or the Light Sensor Challenge are great for exploring the effects of variables.

Debugging Challenge #1

Think about the challenges you've completed in the past units. Take a few a minutes to write a list of the sensors and peripherals you've experimented with. Did you encounter any difficulties or problems with the code or the setup? Did you solve those problems? Did you avoid or ignore problems?

Chose a challenge from the
M:B Padlet that you've been avoiding or feel might be tricky. When you get stuck, try some of the debugging strategies.

Debugging Challenge #2

With a classmate or friend... Create a Debugging Puzzle!
Make blocks of codes with one or several mistakes in them. Give your code to a classmate or friend and see if they can solve the puzzle. Try solving your friend or classmates's puzzle too.

Keeping Track of Your Code & Process

Don't forget to keep track of your code! Use the tracking document or logbook provided by your teacher to save and track your M:B projects.