Are you computer savvy?

Art of Debugging the Code

Art of Debugging the Code

Picture for representational purpose only.

What is debugging?

Debugging the code means to find an issue in the programme/code that you have written to solve a specific problem and repair it. It is one of the important steps to consider if you want to be a good coder. Software developers estimate spending up to 50 per cent of their time debugging the code.

How to debug your programmes?

There are few best practices that you can follow to find and correct errors in your programmes:

1. Try to catch common mistakes: One of the potential mistakes is to just start using the variable without declaring it. Example: to make use of variable 'a', its important to declare int a.

2. Dry run the programme: Dry run is a process of a programmer manually working through their code using a pen and paper to trace the values of variables. Code by hand, walk through your functions and other modules to identify the bugs.

3. Break and Repair: Try to walk through the code, module by module. Make a small change and try a fix, then repeat with another change. It is always easier to catch bugs in a smaller piece of code.

4. Go line by line: Focus on each line of code carefully and use print statements at various checkpoints to catch the line from where the code is working incorrectly.

5. Never get discouraged: Always remember that getting run time errors, compilation errors or even fatal errors is totally normal for a programmer. One should always consider error and debugging as an opportunity to be a better coder.

6. Take a break: When debugging, it is common to fall into the pit for hours and there is no guarantee that you would be able to fix the bug. To avoid such situations, it is advisable that you move yourself away from screens for few hours. It helps you to gain a fresh perspective to solve the problem and improves the productivity.

Debugging is a cyclic process. Keep calm and fix the bugs.

Time to test your Debugging Skills!

Designed by Dr Jyotika Pruthi, Assistant Professor, The NorthCap University, Gurugram

Top Stories

Separatist leader Ashraf Sehrai arrested, booked under PSA

Separatist leader Ashraf Sehrai arrested, booked under PSA

Sehrai is chairperson of the pro-Pakistan Tehreek-e-Hurriyat

13 gaps in mountains along LAC hold key

13 gaps in mountains along LAC hold key

Indian Army has defensive positions ‘tailored’ to hold back ...

What happened that China took away India’s land during Modi’s rule: Rahul asks govt

What happened that China took away India’s land during Modi’s rule: Rahul asks govt

Gandhi has been attacking Modi and his government on the sta...

Worried for Congress: Kapi; Sibal posts cryptic tweet amid Rajasthan crisis

Worried for Congress: Kapi; Sibal posts cryptic tweet amid Rajasthan crisis

Sachin Pilot has remained engaged in a constant battle for p...

BJP trying to topple Rajasthan Govt, will complete full term: Gehlot

BJP trying to topple Rajasthan Govt, will complete full term: Gehlot

Congress CM accuses Opposition party of offering money to hi...

Cities

View All