Debugging experience of a guy “longtime code”

Tram Ho

Debugging is an activity that programmers do quite “frequently” while programming. But not everyone knows how to debug effectively and “fix bugs” right after implementation. So I wrote an article about my personal experience after years of coding and “fixing bugs” persistently. This is also my first post, hope you guys cut me lightly :V

Article source:

Purpose of my Debug

Of course, when reading the title, people think that surely the purpose of debugging is to fix this “bug” and nothing else =]]]. But for me, debugging has more purposes than just fixing bugs. Besides that main purpose, I learned more from experience and how these lines of code work than just letting it run. And from there I will remember and avoid seeing this bug many times later, saving blocks of time. In addition, from finding errors, analyzing errors and fixing them is also a long process, helping me to have much more patience. And here are some of my experiences about debugging.

Use the search skill

Most of you are new to programming or have been a programmer for a long time, encountering “bugs” happens quite often. In that case, everyone has to use google to find the error. But sometimes you don’t know how to write to get the right answers that people need. Here is a tip to help you find the answer easier.

Error + <error name> + <programming language>

For example, with the error below, you would write the following:

error syntax unexpected php

And this is the result:

In some other cases, if you can’t find the answer, you should use your “superior” English or Google Translate to search in the correct context of your bug, because most of the time. Some of the answers are in English, so if you’re not good at English, you need to learn more.

Example: I have an error in a password encryption function and I want to find an optimal and more secure encryption way. I will search like this.

Encrypt passwords in PHP

Know where the error is

Some of you when you first learn to program, when you see an error, you will panic and ask the programming community, and most will be scolded by others because the error is too easy but also ask :V. You can try this way to fix the bug yourself without asking others.

For example, I have an error in ReactJS, right after handing over the bug, I look at where the error is in which line in which file. Next is what is wrong with it.


  • Error message on line 148 and in bundle.js
  • Faulty … is not a function – notice that it’s not a function, stop calling it.
  • This error is generated when a variable that has not been declared or received an error value is returned and used. Causes the code to fail.

After identifying the error, you can search for this error on Google or it’s better to panic

Less use of Debuggers

For me, I don’t know because I know web programming for the first time and code with Notepad++, so debugging programs are quite strange to me. For example php’s xdebug or Nodejs debugger. When I encounter an error, I usually print all the data before the error instead of breakpoint and wait to see where it fails. And not only in one place, I print out many places in the line of code. This helps me see where the error is coming from. And capture how the code runs


The result will be an error like this:

As you can see, the error is reported on line 8. And I suspect it’s from the guy $array (Everyone knows that :V ). I’ll print it out to see what it looks like before it fails. For php is var_dump, in addition you for other languages will have different ways of printing like:

  • var_dump of the PHP
  • console.log of the JS
  • print of the Python
  • ….

When I print it out, I see the error :v. That is $arr[0] is a string (string) and $arr[1] is an int (number). So I have 2 cases:

  • Convert $arr[0] to a number
  • Convert the calculation to

Through this article, I hope that all newbies and veterans will also give their comments and support as a motivation for me to make more new articles. Thank you very much.

You guys can also visit the source to support me:

Share the news now