The style of coding and how to set up debugging code

Source: Internet
Author: User
Tags table name
Coding style is not a rule, each person may have their own coding style and system of organizational style. But a good coding style is very important to remember that any code is read more often than when it is encoded. So take some good style to make it easy to read. Only easy to read, easy to debug, maintenance and re-editing. In the database section, the name of the datasheet is in English, the first word is capitalized, the remainder is lowercase: Each field is in English, all uppercase. The use of English than the use of pinyin is better: the beginning of the alphabet to do the name Ding can make people do not understand, feel puzzled. Uppercase is used when writing SQL statements, which is actually the default by SQL Server. In this way, in the entire code, the SQL statement is very conspicuous, a look at the knowledge, and the size of the data table name in the upper case is very conspicuous, see. When the SQL statement is too long to use the continuation line, the last word followed by a space, so ding to avoid a lot of careless mistakes, to know that many times the error to white format is not correct, and more often comes from the SQL statements.
When an error occurs in the SQL statement, it can be in the Rs. Open ... "preceded by two debug statements:
Response.Write SQL
Response.End
The 1th statement here is responsible for writing the SQL statement passed to the SQL Server to the client, and the 2nd statement ignores the code below the statement and ends the page directly. The client gets the SQL statement, pastes it into SQL Query Analyzer, and gives a very detailed error message.
In fact, it can be written as a process
Sub Debug (Strltem)
Response.Write Strltem
Call Closedb ()
Response.End
End Sub
Quotes are always a very troubling thing. The strings in the VB script code enclose the song in quotation marks, and many times the string itself contains quotes, such as session ("..."), RS ("..."), and many HTML attributes are quoted, and adding a quotation mark in quotation marks and sometimes "&" can be confusing. So be careful when inserting variables into strings so that you can write quotes and "&" symbols symmetrically, so it's not easy to make mistakes.
When writing a script, you should indent the indentation in a regular manner so that the logic is clear. In short, style is very important. Abroad there is a word called "elegent always Pays off", (Thinking in C++,second Edition), which is the experience of foreign experts for many years summarized. Especially in a large system, nonstandard code is a big enemy.

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.