Programmers are eager to collect low-level errors

Source: Internet
Author: User
Summarize the error categories first.
1. fullwidth Problem
2 = and =

3. space issue
4. spelling problems
5. Neglect and forget to do what you should do

6. New things are not very familiar

The following is the details.

One of the most memorable times is the clever addition of a semicolon after a for loop, and

This error occasionally occurs during runtime after a large number of code refactoring.
It took me about one week.

Since then, the braces of my code have been placed behind the lines of code!

For (INT I = 0; I
{
//
}
For (INT I = 0; I
{
//
}

For (INT I = 0; I
//
}
For (INT I = 0; I
//
}

The editor can be helpful when formatting code.

Let's talk about the common low-level mistakes that people once made, or make other friends have a mental preparation. The impulse to take a piece of tofu and hit their own head is several times less.

2. the JSP page inexplicably reports a null pointer and sometimes does not appear. Finally, I found that the JSP code is mixed

Space in the full corner. It cannot be seen when the layout is messy. Then the space is taken as part of the variable name,

But that variable is not commonly used. Tragedy (Engineering)

3 when I used VC, I seem to write something similar to jtable. Everything is fine on my machine. In my boss (in small companies, CTO is also one of the bosses) the machine that runs on will die ........ Then I found that
The machine resolution is 640 × 480, the boss is 800 × 600, and the result array overflows .......

4. I wrote two preparestatements and wrote a preparestatement.exe cutebatch () at the end. I found N for a long time to see the problem.

The business logic layer in the layer-3 architecture is as follows:

Public bool add (hlink. model. favoriteinfo model ){

Return Dal. Add (model)> 0;
}
Public bool add (hlink. model. favoriteinfo model ){
Return Dal. Add (model)> 0;
}
Written

Public bool add (hlink. model. favoriteinfo model ){
Return add (model)> 0;
}
Public bool add (hlink. model. favoriteinfo model ){
Return add (model)> 0;
}
Fortunately, I encountered it once, and later I reported an error in stackoverflow... so I knew what went wrong,

6 struct cxtest_dat

{
...
Word WLEN;
...
}
Int testdata (..., DWORD dwlen );

Use Time:

Cxtest_dat stdata;
Testdata (..., stdata. WLEN );
After automatic expansion to DWORD, the length is always incorrect

7. I often make low-level mistakes, but I don't think it's ridiculous. Every time I find myself making low-level mistakes

And the chance of making mistakes again is much lower.

For example, when I used Java enumeration for the first time, I wrote the following:

/**
* Sqlcommandtype SQL command type Enumeration

* @ Author codingmouse
* @ Version 1.0.0.1
*/
Public Enum sqlcommandtype {

/**
* SQL data query command
*/
Select,
/**
* SQL data insertion command

*/
Insert,
/**
* SQL data modification command
*/
Update,
/**
* SQL data deletion command
*/
Delete

}
/**
* Sqlcommandtype SQL command type Enumeration
* @ Author codingmouse
* @ Version 1.0.0.1
*/
Public Enum sqlcommandtype {

/**
* SQL data query command
*/
Select,
/**
* SQL data insertion command
*/
Insert,
/**
* SQL data modification command
*/
Update,
/**
* SQL data deletion command
*/
Delete

}

When the enumerated parameter value passed by the switch in the method is:

Switch (enumeration variable ){
Case sqlcommandtype. Select
// Intermediate logic processing
Break;
Case sqlcommandtype. insert
......
}
Switch (enumeration variable ){
Case sqlcommandtype. Select
// Intermediate logic processing
Break;
Case sqlcommandtype. insert
......
}

The old syntax reports an error, but I don't know what's going on. Is it clear that the switch branch in JAVA supports enumeration?
After a while, I realized that the case enumeration in the switch branch does not need to be prefixed with the enumeration type.

8 ORACLE: Why do I always prompt errors when writing SQL statements? The statement is too long. After debugging for a day, my eyes are blurred. As a result, a colon is dropped !!

9 once again, when I installed a firewall to run myeclipse, an error was reported, saying that the port was faulty. I thought it was occupied or that the Tomcat problem had not been solved by Baidu and Google for a long time,
Suddenly, it was intercepted by the firewall.

10 struts. xml ------> sturts. xml

11 when speaking in C
If (I = 1)
{
} I was trying to determine whether it was true or false.

Result ......

12 when I modified the configuration file, I found a half-day error because of a space.
13 when maintaining a relatively old project in the company, I wrote such a class intelligently (mainly to share database connections)

Public class dataquery {
// Static connection
Private Static connection con = connectionfactory. getconnection ();

Private collection Getusers (INT groupid ){

Statement ST = NULL;
Resultset rs = NULL;
Try {
St = con. createstatement ();
String SQL = "......";
......
} Catch (exception e ){

E. printstacktrace ();
}
}

// Other query methods share one connection ......

}

Because this project has been running for five years, there is no way to configure the connection pool in struts1.1, so I am smart enough to do this in it.

Alas
The consequences are clear.

Either too many connections, or a connection is Closed somewhere, leading to other methods throwing null pointers.

Fortunately, when something went wrong, I immediately realized this stupid question.
Alas...

14. I made a mistake before and wrote = in while.

Because it was written correctly at the beginning, and later I did not know how to accidentally delete an equal sign. As a result, the program was wrong. It was on an embedded platform,
The development environment is very spam, so I thought it was a bug in the compilation environment.

Yesterday, I wrote a program to call up n bugs. One was to add the return statement in finally, and the program output happened to have other exceptions, so I did not consider this. It took half an afternoon to discover the problem.

The pointer problem is the biggest headache.

15. Enter the full-width semicolon in the Chinese input method. The result is not compiled and no reason can be found.

16 select * from a where a. idin (.....)

17. Write the Java code 10 minutes ago and then write the JavaScript code.

Error:
For (INT I = 0; I
}
Correct:
For (VAR I = 0; I
}
Note: This error is too long to be seen, and I often do the same.

18 my first error is that update is followed by no conditions. As a result, all data is returned,
Update, huh, huh, boss !!!

19 there is the userid parameter passed in by this write stored procedure, and the table involved has The USERID field

The stored procedure has a condition: Update *** where userid = userid;
Turning the database over, I regret it.
Case Insensitive!

20. The input tag type in the form is written as submit. This is normal, but I want to trigger a method in the input type,
Then, the corresponding data is displayed on the page, instead of submitting the entire form. As a result, I have a button in the input, and the page never responds,
New data cannot be displayed. It took two days to discover this simple problem!

21 For (INT I = 0, Len = arr. Size (); I
Temp = arr. Get (0 );
}
... Take the first element after the loop...

22. When I changed the Linux kernel, the buffer length was defined as 128 bytes. Later I changed the solution and needed a 512-byte buffer. I forgot to change the definition. As a result, a value of buffer overflow is assigned, causing the kernel to crash,
I checked for a few months to find out why.

23 when writing SQL stored procedures, the length of the concatenated string is too small, resulting in bad results always appearing during multi-condition queries...

24 VB Code

For I = 1 to n
Next
I forgot to add one.

25 operations on the registry cause overflow, and the heap is damaged, resulting in subsequent code, as long as you apply for new,
An error occurs when malloc is detected.

The function parameter used to write the registry is an outgoing parameter, and the returned value exceeds the defined length.

There is also a segment error in C, array out-of-bounds, difficult to query, all of which are runtime errors, inaccessible or invalid addresses.

26 nested loops use the same variable:

Int I = 0;
While (I
For (I = 0; I
....
}
}
Int I = 0;
While (I
For (I = 0; I
....
}
}

27 what impressed me most is a cycle of C #.

If not followed {}

Adjusted for one afternoon

28 Reference Form class pointer is to directly define the header file, which is not stored in the app, resulting in different pointers and the corresponding member (VC) cannot be called)

29

Sring date = request. getparameter ("date ");

If (! "". Equals ("date ")){

.....
}

........

Sring date = request. getparameter ("date ");

If (! "". Equals ("date ")){
.....
}

........

The lowest error ......
Note: I have made too many mistakes and I used to add double quotation marks.

30. The loop variable is incorrect.
For (INT I = 0; I! = 5; ++ I)

{
For (Int J = 0 J! = 5; ++ I)
{

31. Remember to save the program code in a directory named after Chinese characters and run it according to F9 compilation,

I have always failed to run. I am looking for help everywhere. I 've searched for the whole project team, and I think it's strange. After a long time, I can't solve it. I 've exhausted all the methods,

That is, it cannot run normally. Later, I copied the program again and changed a folder to solve the problem.

Since then, I have never dared to put the program in a Chinese folder. I still remember this in year 56.

32. When packaging, the database configuration file is not modified, but the user runs the test database.

33 when I wrote a conditional statement last night, I lost the IF () brackets into the full-angle format. But the if brackets are nested. In anger, all Chinese input methods are removed, and today they are installed again.

34. After imagebutton was used at one time, the result was submitted again using JS, And the redundant data was taken. Later I realized that imagebutton would submit ~

Case statement for 35 Databases

Case when then
I always forget to write end.

36. Use full-angle commas to write SQL statements, and then debug the statements, which always reports SQL statement errors. Many colleagues help me find the errors. Finally, they find that they have been despised for a long time.

37. I recently maintained a website of my company and found that the person who wrote the program also used a Global static connection. As a result, when many people access the website, the error of data column does not exist,
He used a variable like this in the data layer. As a result, the program I wrote was faulty. Since the modification, no data Column exists.

Note: you must know what it means to use static,
Otherwise, you are still relatively safe, even if it is a waste of memory. But the sooner the problem occurs, the better.

38. 0 in the name of a variable is written as O. I don't know how many brothers can find it without glasses.

39 form is written as from .......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.