Jun 02, 2021 Article blog
Program for 5 minutes, check code for 2 hours!
In the programming career of programmers, inevitably deal with BUG, and even some programmers are abused by BUG suffering.
When someone points out that the programmer code has BUGs, the programmer's answers are different:
1, impossible ah, running on my computer no problem ah!
2, I haven't touched this code in a week!
3, nothing, I change a line of code on it, does not affect the program.
The BUG of the code makes people doubt life. How do I reduce the BUG of my code?w3cschool shares a few tips here:
0, don't turn a blind eye to the warning
Believe that a lot of programmers will use IDEA, use it to knock code, sometimes there will be a warning, then you can not turn a blind eye to the warning.
Our goal is to write clean code and do wind-like men!
1, programming habits
Grow melon beans, good programming habits can greatly reduce the number of BUG. For example, if you have to write else, even if else is an empty statement.
2, the time to write code
For programmers, don't stay up late writing code. Some programmers are still typing code at 11 p.m.
Although you feel clear-headed yourself, you may find a lot of problems the next day when you self-test, or QA test.
We generally don't advocate long-term overtime writing because that causes the bug rate to skyrocket.
3, verification
Multi-verify before submitting tests, including automated tests, manual running use cases, and more.
There is a good word, don't be afraid of trouble, otherwise you will be in trouble all your life.
4, careful design
Before programmers can write code, they must have a clear understanding of the entire structure of the code and the logical structure.
5, avoid interference
When some programmers knock on code, they often listen to music while typing code, which is not only inefficient, but also more likely to generate BUGs.
6, comments
Write notes, write notes, write notes. Say the important things three times.
This is because early comments are good for subsequent development when bugs are easily reduced.
Since modifying the comment template, the whole person has become more spiritual and has significantly fewer bugs, as shown in the figure: