Digital Tech Notes (JSS1 - SS3)

Debugging In Computer Programming

Learn what debugging means, why it matters, and how to find and fix errors in code. A complete JSS 2 Computer Studies guide aligned with the Nigerian



INTRODUCTION:

Have you ever typed a set of instructions and the computer just refused to do what you wanted? Maybe it showed a strange message, or the program stopped working halfway. If this has ever happened to you, then you have already experienced what programmers deal with every single day.

Writing code is exciting, but no programmer — not even the most experienced software developers working at big tech companies in Lagos, Abuja, or Silicon Valley — writes perfect code on the first try. Mistakes happen. The good news is that there is a skill for finding and fixing those mistakes. That skill is called debugging.

In today's world, where mobile apps, school management systems, banking platforms like Opay and Kuda, and even government websites all run on code, debugging is one of the most important skills any computer user or programmer can learn. For JSS 2 students in Nigeria, understanding debugging is not just about passing exams — it is about preparing for a future where technology is everywhere.

This lesson will walk you through what debugging means, why it is important, the types of errors you can find in code, and how to fix them step by step, with simple examples you can relate to.


LEARNING OBJECTIVES

By the end of this lesson, students should be able to:

  1. Define debugging in simple and clear terms
  2. Explain the importance of debugging in programming
  3. Identify the different types of errors that occur in a program
  4. Describe the steps involved in finding and fixing errors in code
  5. Demonstrate basic debugging skills using practical examples
  6. Apply knowledge of debugging to solve simple coding problems

WHAT IS DEBUGGING?

Debugging is the process of finding, identifying, and fixing errors or problems in a computer program. These errors are commonly called "bugs," and the act of removing them is called debugging.

The word "bug" in computer science has an interesting history. Back in 1947, a real moth (an insect) flew into a computer and caused it to malfunction. The engineers found the moth and taped it into their logbook, writing "first actual case of bug being found." Since then, any error in a program has been called a bug, and fixing it is called debugging.

So when your program is not working correctly, you go bug-hunting — and that hunt is what we call debugging.


WHAT IS A BUG IN PROGRAMMING?

A bug is simply any error, flaw, or unexpected behaviour in a computer program that causes it to produce wrong results or stop working entirely.

Think of it this way: imagine you are giving your younger sibling instructions on how to make Indomie noodles. If you mistakenly tell them to add sugar instead of salt, the noodles will taste terrible. That wrong instruction is the "bug." Debugging would mean going back to your instructions, finding where you wrote "sugar," and correcting it to "salt."

In programming, bugs work the same way — wrong instructions lead to wrong results, and debugging helps you go back, find the wrong instruction, and fix it.


TYPES OF ERRORS IN PROGRAMMING

There are three main types of errors that programmers encounter. Understanding them is the first step to fixing them.

Syntax Errors

A syntax error happens when the programmer breaks the rules of the programming language. Every programming language, just like every human language, has its own grammar rules. When you break those rules, the computer cannot understand the code.

Example: In many programming languages, you must put a colon or a bracket in a specific place. If you forget it, the program will not run at all.

A simple analogy: Imagine writing "I goes to school" instead of "I go to school." The meaning is clear to you, but it breaks the rules of English grammar. A syntax error is like that — the programmer made a grammar mistake in the code.

Logic Errors

A logic error is trickier. The program runs without any complaints, but the result it gives is wrong. The computer did exactly what you told it to do — but what you told it was incorrect.

Example: A student writes a program to calculate the average of three scores. Instead of adding all three and dividing by 3, they divide by 2 by mistake. The program runs fine, but it gives the wrong average every time.

This is a logic error — the code is grammatically correct, but the thinking behind it is flawed.

Runtime Errors

A runtime error is one that only appears while the program is actually running. The code looks fine, it starts running, and then suddenly something goes wrong and the program crashes or freezes.

Example: Imagine you write a program that divides a number by another number. Everything looks fine. But when a user enters zero as the number to divide by, the program crashes — because you cannot divide any number by zero in mathematics. That crash is a runtime error.

A local example: Think of a generator that starts perfectly, but suddenly shuts down while in use because it ran out of fuel. Everything was fine at the start, but a problem appeared in the middle of operation. That is what a runtime error feels like.


WHY IS DEBUGGING IMPORTANT?

Debugging is one of the most critical stages of programming. Here is why it matters so much:

It ensures that programs work correctly. A buggy banking app could show the wrong account balance. A buggy school result system could print the wrong grades for students. Debugging prevents these kinds of dangerous mistakes.

It saves time and money. In real-world software development, fixing a bug early is much cheaper than fixing it after millions of people are already using the software. Nigerian tech startups and companies understand this very well.

It improves a programmer's thinking skills. Debugging teaches you to think carefully, trace problems step by step, and never give up — skills that are useful not just in coding but in everyday life.

It leads to better quality software. Every app you use on your phone — whether it is WhatsApp, your school's portal, or a government service website — works well because developers debugged it thoroughly before releasing it.

It builds confidence. When a student successfully finds and fixes a bug, it builds confidence and deep understanding of how their code actually works.


HOW TO FIND AND FIX ERRORS IN CODE (THE DEBUGGING PROCESS)

Debugging is not just guessing and hoping for the best. There is a logical process good programmers follow.

Step 1 — Identify That There Is a Problem

The first step is to notice that something is wrong. This could be an error message on the screen, a wrong output, or a program that refuses to run. Do not panic. Every programmer faces this.

Step 2 — Understand What the Program Is Supposed to Do

Before you can fix a problem, you must clearly understand what the program should be doing. Ask yourself: What was the expected result? What is the actual result? What is the difference between them?

Step 3 — Locate the Error

Now search for where in the code the problem is coming from. You can do this by:

  • Reading through the code carefully from the beginning
  • Checking the line number mentioned in the error message (if there is one)
  • Testing small sections of the code one at a time
  • Using a technique called "print statements" — adding temporary lines that display values at different points in the code so you can see where things go wrong

Step 4 — Fix the Error

Once you have found the bug, correct it. This might mean:

  • Fixing a spelling mistake in the code
  • Correcting a wrong mathematical formula
  • Adding a missing bracket or punctuation
  • Rewriting a section of code with better logic

Step 5 — Test the Program Again

After fixing the bug, run the program again to see if it now works correctly. Sometimes fixing one bug reveals another one hiding nearby. Keep testing until everything works as expected.

Step 6 — Document What You Did

Good programmers keep notes. Write down what the bug was and how you fixed it. This helps you and other programmers in the future.


PRACTICAL EXAMPLES OF DEBUGGING

Example 1 — Syntax Error

A student writes this simple Python code to print a greeting:

print("Welcome to JSS 2 Computer Studies"

When they run it, they get an error. Can you spot the bug? The closing bracket is missing at the end. The correct code should be:

print("Welcome to JSS 2 Computer Studies")

That small missing bracket was the bug. Fixing it removes the error.

Example 2 — Logic Error

A student writes a program to find the area of a rectangle. The formula for area is Length multiplied by Width. But the student wrote Length plus Width by mistake. The program runs without errors, but the answers are all wrong.

The bug here is a logic error — wrong formula used. The fix is to replace the addition with multiplication.

Example 3 — Runtime Error

A student writes a program that asks a user to enter a number and then divides 100 by that number. When the user types zero, the program crashes. The student needs to add a check: "If the number entered is zero, display a message saying division by zero is not allowed."

This fix prevents the runtime error from occurring.


PRACTICAL APPLICATIONS OF DEBUGGING IN NIGERIA

Debugging is not just a classroom activity. It has real-world applications all around us in Nigeria:

Mobile Money Apps: Apps like Palmpay, Opay, and Kuda must be thoroughly debugged. A single bug could cause someone to lose money or receive wrong transaction alerts.

School Result Portals: Many Nigerian secondary schools and universities use software to generate and publish results. Bugs in these systems could lead to wrong grades being published — which is why developers must debug carefully.

Government Platforms: Platforms used for NIN registration, WAEC result checking, JAMB registration, and tax payments must all be debugged before launch to avoid errors that affect millions of Nigerians.

Hospital Management Systems: In hospitals across Nigeria, software is used to manage patient records. A bug in such a system could result in a patient receiving the wrong medication — a life-threatening consequence.

Everyday Apps: Even the apps you use daily on your phone to stream music, chat with friends, or play games were debugged hundreds or thousands of times before you downloaded them.


ADVANTAGES OF DEBUGGING

  • It helps produce high-quality, error-free software
  • It protects users from dangerous mistakes caused by faulty programs
  • It helps programmers learn and improve their coding skills
  • It makes programs run faster and more efficiently
  • It builds problem-solving and critical-thinking skills in students and developers

DISADVANTAGES / CHALLENGES OF DEBUGGING

  • It can be time-consuming, especially in large programs with thousands of lines of code
  • Some bugs are very difficult to find and can frustrate even experienced programmers
  • Fixing one bug can sometimes accidentally create another
  • Without proper tools and experience, debugging can be overwhelming for beginners

ETHICAL CONSIDERATIONS IN DEBUGGING

As students learning to code and debug, it is important to think about how your skills are used responsibly.

Always test and debug software before sharing or deploying it, especially if others will rely on it. A buggy program shared carelessly can cause harm to users.

Do not introduce bugs deliberately into someone else's code. This is unethical and can be considered a form of sabotage.

When debugging software that contains personal data — such as a school result system or health record — respect people's privacy. Do not access or share private information during the debugging process.

If you find a bug in a software system used by others, report it responsibly instead of exploiting it for personal gain. In the world of technology, this is called "responsible disclosure."


CLASSROOM AND HOME ACTIVITIES

Activity 1 — Spot the Bug

Your teacher writes three short programs on the board, each containing one deliberate error. Students work in pairs to identify the type of error (syntax, logic, or runtime) and suggest how to fix it.

Activity 2 — Debug My Recipe

Write the steps for preparing a simple Nigerian dish (like jollof rice or noodles) as if it were a computer program. Swap your "recipe program" with a classmate. Each student finds and fixes errors in their partner's recipe-program.

Activity 3 — Error Journal

For one week, each student keeps a small notebook. Whenever they encounter any kind of error — in a program, a math calculation, or even a real-life plan that went wrong — they write down: What went wrong, Where it went wrong, and How they fixed it.

Activity 4 — Debugging Challenge

Using any available programming tool (Scratch, Python, or even a pseudocode exercise), students write a simple program, introduce a deliberate bug, and exchange with another student to find and fix the bug.


ASSESSMENT QUESTIONS

Section A — Objective Questions

  1. What is debugging? a) Writing new code for a program b) The process of finding and fixing errors in a program c) Deleting an old program from the computer d) Installing software on a computer

  2. Which type of error causes a program to crash while it is running? a) Syntax error b) Logic error c) Runtime error d) Spelling error

  3. A student writes a program to multiply two numbers but uses addition instead. What type of error is this? a) Syntax error b) Runtime error c) Logic error d) Formatting error

  4. The word "bug" in computing came from: a) A virus found in a laptop b) A real insect found inside a computer in 1947 c) A type of software used in schools d) An error message displayed by Windows

  5. Which of the following is NOT a step in the debugging process? a) Identify the problem b) Delete the entire program and start again c) Locate the error d) Test the program after fixing it

Section B — Theory Questions

  1. Define debugging and explain why it is important for programmers and software users in Nigeria.

  2. Describe the three types of programming errors. Give one example of each type.

  3. Outline five steps a programmer should follow when debugging a program. Explain each step briefly.


SUMMARY

In this lesson, we covered the following key points:

  • Debugging is the process of finding and fixing errors (bugs) in a computer program
  • The three main types of errors are syntax errors, logic errors, and runtime errors
  • Syntax errors break the grammar rules of the programming language
  • Logic errors occur when the program runs but gives wrong results due to flawed thinking
  • Runtime errors happen while the program is running and often cause it to crash
  • The debugging process involves identifying the problem, locating the error, fixing it, and testing again
  • Debugging is used in real life across banking apps, school systems, hospital software, and government platforms in Nigeria
  • Good programmers debug responsibly and ethically

CONCLUSION

Every great programmer started exactly where you are right now — learning the basics and making mistakes along the way. What separates good programmers from frustrated ones is not the ability to write perfect code the first time. It is the ability to find what went wrong and fix it calmly and systematically.

Debugging is that ability. It teaches patience, logical thinking, attention to detail, and perseverance — qualities that will serve you not just in Computer Studies, but in every area of life.

As Nigeria continues to grow its tech industry, with more young Nigerians building apps, websites, and software solutions, the ability to debug will remain one of the most valuable skills you can have. Keep practising, keep learning, and never be discouraged by a bug. Every bug you fix makes you a better programmer.


FREQUENTLY ASKED QUESTIONS (FAQ)

What does debugging mean in simple terms? Debugging simply means finding and fixing mistakes in a computer program. Just like you proofread an essay to find and correct errors, a programmer debugs code to find and fix problems.

What are the three types of errors in programming? The three types are syntax errors (breaking the grammar rules of the programming language), logic errors (wrong thinking that produces incorrect results), and runtime errors (errors that cause the program to crash while running).

Why is debugging important for students? Debugging teaches students critical thinking, patience, and problem-solving skills. It also ensures that any program they write actually works correctly and can be used by others safely.

How do you find a bug in a program? You can find bugs by reading through the code carefully, checking error messages, testing the program step by step, and using print statements to track what the program is doing at each stage.

What is the difference between a syntax error and a logic error? A syntax error prevents the program from running at all because it breaks the rules of the programming language. A logic error allows the program to run but produces wrong results because the programmer used incorrect reasoning or formula.

Can a program have more than one bug at the same time? Yes. A program can have multiple bugs at once. This is why testing after fixing one bug is important — sometimes fixing one bug reveals another one that was hiding nearby.


This content is written in alignment with the Nigerian NERDC Computer Studies curriculum for Junior Secondary School 2 (JSS 2). It is intended for educational purposes and is suitable for classroom use, school blogs, and educational websites.

I am Echofu George Adah, the Pioneer of Digital Tech Note and the Founder and Chief Executive Officer of GeoWeb Technologies Limited, an information technology company committed to providing cutting-edge ICT solutions.