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

Source: Internet
Author: User
This is a matter of concern to many web creators and developers alike. There is probably no magic, you can guarantee to reduce your style sheet to a percentage of how much, but reasonable CSS coding and organizational skills, it does help you to more efficiently write more efficient code, naturally, the size of the style sheet reduces the time to download.

First, typesetting:

1. Add the appropriate spaces between the keywords and the operators.

2. Blank lines between the relatively separate blocks and blocks

3. Longer sentences, expressions, etc., are divided into multiple lines of writing.

4. The new line to be adjusted to fit the indentation, so that the layout is neat, the statement is readable.

5. Long expressions to divide a new line at a low-priority operator, the operator is placed at the top of the new line.

6. If there are long expressions or statements in the circular, judgment and other sentences, then the adaptation is to be divided.

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

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

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

The 10.c/c++ language is a block of blocks defined with curly braces ' {' and '} ', when the program block is written, ' {' and '} ' should have exclusive lines and be in the same column, and align to the left of the statements referencing them. The beginning of the function body, the definition of the class, the definition of the structure, the definition of the enumeration, and the procedures in the If, for, do, while, switch, case statements are indented as above.

Second, the note

1. Note to be simple and clear.

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

3. Where necessary, note the amount of comments to be moderate. The contents of the note should be clear, concise and accurate, and prevent the ambiguity of the annotation. Keep the comment adjacent to the code it describes, which is the nearest principle of the annotation.

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

5. Comments on the data structure should be placed in the adjacent position above it, not placed 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 on the top or right side of them.

7. Global variables have more detailed comments, including descriptions of their functions, range of values, which functions or procedures to access it, and considerations for access.

8. The header of each source file must have the necessary annotation information, including: file name, version number, author, generation date, module function description (such as function, main algorithm, the relationship between the internal parts, the file and other file relationships, etc.), the main function or process list and the history of the file modification records.

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, invocation relationship and description of called relationship, etc.

Third, the name

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

2. Longer words take precedence over the first few of the words, and use parentheses to clarify the order in which the expressions are manipulated, avoiding the default precedence.

3. Use of the Hungarian notation
  • 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.