Debugging


Today I really want to talk about debugging. Because no matter whether you are a beginner or an experienced developer, you write bugs in the code.

However, we can study the tools and bugs to find solutions that can help us be more efficient in reducing the bugs we create.

Learn the basics of the tools you often use

Learning the basics of any tools you often use helps you reduce the number of bugs you create while coding.

Syntax highlighting

If you are using an IDE, for example, VS code, it has the syntax highlighting function. Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names. It really helps you to recognize the errors: wrong methods, variable names, etc… Please set up the syntax highlighting function in your IDE.

SYNTAX

If you start using a new language, for instance, JavaScript, you just pick a built-in method or function you use want to use and ask yourself:

‌‌What kind of argument does this take? ‌‌What does this return? ‌‌What happens if an invalid argument is supplied?

Do some research before you call it and don’t surprise yourself with unexpected behaviors.

Familiarize yourself with common error messages
1. Syntax Errors

It is often very easy to fix an error or a bug if you have familiarized yourself with the corresponding error messages. Programming languages are strict about their rules and they will throw errors whenever those rules are violated.

For example, in javascript, if

console.log(school.name);

gives us an “undefined” error message, you should know the object or property we are accessing is not available. You should give back and check if you have this school object and if the school object has an attribute called “name”.

2. Logic errors

Logic errors are very tricky to deal with because they always seem like there is no error – but you still don’t get the expected result.

For example, if you want to retrieve some data from the database and send it back to the UI, the web page didn’t show the data. You can always put a console.log/print statement inside your frontend/backend code to check if the get request was sent to the right place, if the data was successfully retrieved from the database, and if the data was loaded to the page. This will really help you narrow down the scope of the error where it happened.

Fix or Remove Bugs

After finding a bug, we have to fix that bug. Sometimes, once you understand what the bug is, you can simply fix it without stress. However, there are more times when our understanding/knowledge yields no solution no matter how hard we try.

Instead of wasting time, just Google the error message! I had thousands of times found the solution on the StackOverflow.

In conclusion, debugging is a major skill that all software developers must cultivate. It is at the core of coding, and if you do it well, it can make you a better developer.

Don’t let the bugs scare you away from the coding. I know, sometimes, debugging is really annoying no matter how hard you try, the bug is still there. However, fixing a worrisome bug always brings about great excitement. When you’re getting more familiar with the syntax and error message and using different debugging methods, your software development skills will not be the same again, I promise.

Hope you will take some time to explore some debugging tricks!

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *