DEV Community

loading...

Debugging Tips for A Complete Beginner

pandurijal profile image Pandu Rijal Pasa ・2 min read

Debugging is hard; especially for those who are just getting into code. Often this leads these people to wave the white flag in the early stages of their programming life. So here I have brought you some tips which can help you get rid of bugs in your program:

Clarify everything

Before doing anything, try to ask: what do I expect to run? Then, ask the following question: what happened instead?. Ideally, this should be documented, in detail. To begin solving the problem, the first thing you have to know is why is this becomes one.

Reproducing the bugs

We should be able to track the bugs on our code, hence we need to reproduce them in our dev environment. Keep in mind that ‘aiming in the dark’ is not the best approach to solve the issue. It might solve the issue, but also might make the problem bigger. So, reproduce!

Read & Google error message

Whenever you face any error, read carefully what the compiler tries to tell you. Often this error message comes with file location and even the line number of the error that happened. Jump into that line! This is a great clue before you start to fix the bugs.

Print out every step

You have to be sure that every line of your code is working well. I mean, every single line. If you are not so sure about one or two, giving them print out (e.g console log) of a random string on every step is not a bad approach. As long as don’t forget to delete it once the problem is gone.

Try and try

The substance of the debugging process is to identify the problems and solve those issues. Some of them would be harder than you have ever imagined. Keep trying and do code-run-repeat until it solved and you will learn a lot from this process.

Discussion (0)

pic
Editor guide