Beyond the boundaries

Strategies in debugging

Every developer goes through a stage of debugging. But at times the time taken to debug the product is greater than the time taken to develop the product. Following the below steps in debugging can save your valuable time.

Reproduce bug before changing code

In many cases, developers read the description of the bug, make random assumptions of the bug and start changing the code. After all, even though the developers think it is done, the bug has not been fixed and instead has created more bugs in the system. In order to avoid wasting time in needless bug fixes and code changes, it is better to reproduce the steps and make sure how the bug occurs. Writing some test cases to identify the bug can also be done in this situation.

Understand stack traces

The ability to understand stack traces can save hours of your precious time. The root-cause which leads to the bug can be wrapped inside a couple of layers. So understanding and managing to go through stack traces will be a great way to follow the error code. Other than that, inspecting the console and the network is a commonly used way to identify the main cause of your bug.

Know error codes

HTTP error codes are fundamental in almost all the types of apps these days. So, knowing the meaning and having an experience in the error codes can be a great way to identify where you have gone wrong. These types of errors can be occur in database drivers and protocols as well. If you ever see an error code, best thing is to Google it go through the docs on the way to get rid of the error. Below are a few examples of error codes and the cause of the errors.

  •        404 - You might have the wrong URL in your app
  •        401 - Your credentials are likely wrong
  •        429 - You’re making too many requests

Using git bisect

Git now provide services not only for version control, but it has few commands to help you debug your source code projects.  git bisect can help you search your Git commit history to determine when a bug was introduced. This is more efficient when you have a clean commit history and it is done through binary searching commits and asking you to verify whether or not the bug exists in each commit.

Get help from social sites

In some cases, people are not able to fix the bug at the end of the day. That is the time for you to get the help from social platforms or communities. These problems can be issues with libraries, integrating tools or from an external dependency. Issue reviews in most open source projects in GitHub give a clear idea of the project issues. Finding the problems in these issue reviews can be great help when identifying the cause of the error. In addition, stack overflow serves as a platform for users to ask and answer questions via active participation, to vote questions, answers up or down, and edit questions and answers.

The strategies in debugging can vary from one person to another. So identifying the best way to efficient debugging can make you save your valuable time. So, in order to understand what suits you the best, start coding.

Shavindi Pathirana



Post comment