Whether there is a bug in the project team, or a bug in the code left by a predecessor, the programmer is determined.

Many programmers were killed by code torture pain. But on the positive side, code bugs are great learning opportunities.

The ability to deal with bugs is self-evident and is often considered in an interview.

W3cschool shares 5 tips for dealing with bugs:

0, binary legal bit

Binary legal bits are a common bug handling technique.

By dichotomy, that is, by annotating the logic of the program bit by bit and constantly troubleshooting, the scope of possible problems can be completely reduced.

Binary debugging method every time encountered thorny bug, basically can solve, can be called the program to walk the code necessary tricks.

1, IDE built-in debug function

The IDE can be used to view the assignment of some complex data structures, and the debug effect is also a drag.

2, discuss

The most difficult part of dealing with bugs is not how to solve the problem, but how to locate the bugs in the code.

Once we found the Bug, the solution was obvious.

Sometimes it’s a good idea to discuss it with a colleague, who may not be familiar with the code, but every time we encounter a nasty bug.

Especially when dealing with tough bugs, there is sometimes no need to go it alone.

3, print

The Print method is to Print the value of the variable in question through this function.

It turns out that most programs work quite well with this method.

4. Rewrite it

Most bugs are typo. If you think the code is a mess, then you can start over.

In order to avoid being killed by evil code, we can also use the killer technique when necessary – rewrite the code!



Author: Anonymous

Source: 51 cto