Coding specification learning experience

xiaoxiao2021-03-06  19

Xiong Bin

2005.3.2

When I was written before writing, I always want to write the codeful code, but what the so-called specification, I specifically, how the words are understood, but I have not found the answer. I used to use some of the rules introduced by some authoritative books before processing this issue, but there is no complete unified rule.

After reading the code specification, I think it is very helpful. The so-called coding specification should refer to: 1, coding style; 2, program efficiency and safety two large aspects.

At the time of encoding, the most basic thing is naming the variables, functions, etc. in the program. In the past, most of me will be named according to the rules named after using meaningful English, but sometimes encountered a more cumbersome name, or for the convenience of the picture, it will also use some pinyin, or a meaningful letter combination. name. I used to use UNIX traditional underline writing rules, but there will be some other writing forms in the program. These irregular naming, writing methods I will change it in the future.

I don't use spaces in the previous program. It is now understood that when two or more keywords, variables, constants are paired, between multiple parameters of the function, and when used to binocular or triangular operators, the purpose is to make Clear code is clearer.

Write an comment and write programs as important, combined with some of your previous habits, I think there is a few points you should pay attention to your future work. First, the function head and the file header make a brief introduction to the code you want to write, annotate some of the variables that appear; the second, the comment is the introduction of the function, not a simple introduction to the implementation process; The style of the comment should be unified. I used to use "/ * ... * /".

There is a lot of rules for increasing the code efficiency. When you write a Web Server program, the final phase is optimized. Some of the rules are also used, for example: the workload in the circulation minimizes; avoiding the cyclic body to set the judgment statement, the loop speech should be placed in the code block of the judgment statement; when programming, the difference is 1 error, etc. But there are still many ways, no attention, or more, don't know what to consider.

There are still many rules, such as 4.1.3 Section Rule 1, the data structure of the data structure and the unreasonable organization, usually know, but do not pay attention to this problem when actual encoding. These I have to pay more attention in the future.

In terms of operations involving the memory, there are two places to pay particular attention. One is the memory allocated in the process / function, and is released before the process / function exits; it is to prevent memory operation, which is often one of the main mistakes of software systems. There must be an exception handler if these molten operation errors must be added.

When the function is implemented, comply with the principle of high fans and reasonable fans. When the function is constructed, it is minimized as much as possible, so that the functionality is unique.

In short, after reading the code specification rules, I have a systematic understanding of the rules you have to comply with. I will comply with these rules in the future, and understand the body, I hope to truly integrate the way.

转载请注明原文地址:https://www.9cbs.com/read-49286.html

New Post(0)