Login Register
Follow Us

Art of Debugging the Code

Show comments

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

Show comments
Show comments

Trending News

Also In This Section


Top News



Most Read In 24 Hours