How to avoid bugs for entry-level programmers

   For many friends who have just worked for one or two years, the most troublesome thing is that bugs are flying all over the sky, and the test girl calls you affectionately every day.
    In fact, many bugs can actually be avoided when they are written, so let's talk about a few common bug incubators.

1. It is taken for granted that the value passed from the front desk will not be wrong, and no further testing is done in the background. For example, when we write an interface, the client, the parameters passed to us are numbers. As a result, due to a problem with the client's data initialization, when fetching a number, a letter is passed over, which is very likely to cause a type conversion exception on the server side.

2. Does not pay attention to exception handling. Many times, when our program is running, a 500 error suddenly occurs. We break the point and find that it is a time format conversion error, and then we can only handle this exception or add a test. Make errors controllable, and do something about the places where errors are prone to occur (I have been planted in it many times, I used map to traverse the list, but naively thought that the list could not be empty).

3. Low-level mistakes, typos, capitalization, etc. Self-testing, self-testing, or unit testing, the important things have to be said three times. Don’t expect the test girl to control everything for you, otherwise, haha, you will have a lot of time to fix bugs. Doing a little bit more yourself and fixing the low-level mistakes will save you a lot of time.

4. It is really important to understand the transaction management of the framework itself. One of the most terrifying things is that multiple update statements need to be executed under one button. Once an error occurs in one of the updates, it rolls back itself, the previous update is updated, and the subsequent ones are not executed due to an error, so , there is a lot of dirty data in the database.

5.sql. This is really nothing, when writing, when changing, when reporting an error, first go to pldql or other sql editor to execute it, and the wrong location and specific errors will come out.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326549913&siteId=291194637