More efficient CSS code writing 1th/3 page _ Experience Exchange

Source: Internet
Author: User
Tags comments data structures
This is a problem that many web-makers and developers are concerned about. There's probably no magic to make sure you shrink your stylesheet to a percentage of it, but reasonable CSS coding and organizational skills can help you write more efficient and efficient code more efficiently, and naturally, the reduction in stylesheet size can reduce the time to download.

First, typesetting:

1. Add the appropriate space between the keyword and operator.

2. A relatively independent block and blocks between the empty line

3. Longer statements, expressions, and so on, to be divided into multiple lines of writing.

4. The new line should be adapted to indent, so that the layout is neat, the statement can be read.

5. Long expression to divide the new line at the lower precedence operator, the operator is placed at the top of the new line.

6. If there are longer expressions or statements in the statements of circulation, judgment, etc., it is necessary to make an adaptive division.

7. If the parameters in the function or process are longer, the appropriate division should be made.

8. It is not allowed to write multiple phrase sentences on a single line, that is, one line to write a statement.

9. The beginning of a function or process, the definition and circulation of the structure, the code in the judgment, and so on, are indented styles.

The 10.c/c++ language defines a piece of code with braces ' {' and '} ', and when writing a program block ' {' and '} ' should be exclusive and in the same column, and left aligned to the statement that references them. At the beginning of the function body, the definition of the class, the definition of the structure, the definition of the enumeration, and the procedure in the If, for, do, while, switch, case statements, use the Indentation method as above.

Second, note

1. The annotations should be simple and clear.

2. Edge Write code Edge annotation, modify the code at the same time modify the corresponding comments to ensure that the annotation and code consistency.

3. If necessary, note that the amount of comments should be moderate. The content of the annotation should be clear, clear, meaning accurate, prevent annotation ambiguity. Keep the annotation adjacent to the code it describes, the nearest principle of the annotation.

4. Comments on the code should be placed adjacent to the position above it, not below.

5. Comments on data structures should be placed adjacent to them, not below; comments on each field in the structure should be placed to the right of the field, and comments from different fields in the same structure should be aligned.

6. Comments on variables and constants should be placed adjacent to or to the right.

7. Global variables should be commented on in more detail, including descriptions of their functions, range of values, which functions or procedures to access it, and considerations for access.

8. To have the necessary annotation information on the head of each source file, include: file name; version number; author; build date; module functional description (e.g. function, main algorithm, relationship between internal parts, relationship between the file and other files); main function or process list and history modification record of this document.

9. Before each function or procedure, you need to have the necessary annotation information, including: function or procedure name, function description, input, output and return value description, call relation and invoked relation description, etc.

third, naming

1. Shorter words can be abbreviated by removing "vowels";

2. A longer word is preferable to the first few characters of a word, and the order in which the expressions are defined in parentheses is used to avoid default precedence.

3. Use of the Hungarian notation
Current 1/3 page 123 Next read the full text
Related Article

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.