How to solve bugs in projects (ideas)

In our project development, we always encounter various bugs. For me, being able to quickly find bugs, analyze bugs, and solve bugs is the biggest challenge to my ability.

Therefore, we must first clarify what types of errors are often encountered in project development?

There are three major categories of error types:

1. Grammatical errors

        Let us clarify how our grammatical errors should be repaired from the form of their errors. The so-called grammatical errors are a type of errors that occur when our ID development tools are used, for example:

When we define variables, assume const. When writing const, if there is a spelling error in the word, then we can call it a grammatical error . This type of error will be used when using the built-in development tools of VSCode . An obvious red wavy line will appear to tell you that we have made a code error. Of course, we may also use other tools to better correct grammatical errors when writing code. For example, use:

  • ESLint : What we implement is the detection operation of the rule constraints of the code. Using it can better help us avoid some grammatical errors. Parse whether our brackets match.
  • Prettier : The code tool corrects our grammatical errors. So why can the Prettier code formatting tool correct grammatical errors? It's because when we make a syntax error, the code formatting process fails. Then we make it clear that when writing code, corresponding error messages appear in different locations.
  • Code Spell Checker : It is also a code spell checker plug-in to determine whether there is any wrong writing of the code when we write the code.
  • Error Lens : is a tool that displays our grammatical errors in real time
  • GitLens : It can help us determine where we are through version rollback management when dealing with syntax errors.

All in all, our syntax errors are the types of errors that occur in the development environment. We can use various tools and our development habits to find, avoid and solve our bugs.

2. Compilation error

What is a compilation error? Compilation errors are a type of error that occur when our program is running

You can see the error message through the console. At this time, there will be requirements to improve our capabilities. Can we understand the console information? If we cannot understand the console error message, there is no way. Analyze what the current problem is. If we can understand the error message of our console, then we can try try-catch in the program or we can use log records to clarify under what circumstances our compilation will occur. Errors, so the ability to cause programming errors mainly lies in the ability to view and analyze existing problems.

3. Logical errors

What is a logical error? Neither syntax errors nor compilation errors will occur.

So how to solve it?

  • Console printing: The function of console is very powerful. For example, console printing processing is not only console.log, but also console.debuger, console.error... to print to confirm where our problem occurs.
  • Program debugger: Use the debugger to set breakpoints at the program location we specify. We can set conditional breakpoints: a pause when the conditions are met, and only under specific conditions, specific logic can be debugged. So, at this time, it is very useful for us to use the program debugger
  • Tool breakpoint debugging

Reduce bugs with TypeScript:

  • static type checking
  • Type annotations and inference
  • Catch errors early
  • Smart code completion
  • Code readability and maintainability

Bug handling is not just a technology, it is a process, and it is even a better opportunity for our team collaboration and personal growth!

Guess you like

Origin blog.csdn.net/Aan___/article/details/135842584