计算机源代码编写规范(Code for compiling computer source code)
计算机源代码编写规范(Code for compiling computer source code)
Code for compiling computer source code
File number:
NW506104
Effective date:
2000.3.20
Controlled number:
Security: Secret
Revision: Ver2.1
Modify state:
PageCount
Six
text
Six
appendix
Zero
Organized by: Ma Yunsheng
Audit: Yuan Huai
Ratification: Meng Li
Shenyang Dongda ALPINE software Limited by Share Ltd
(all rights reserved copy)
File change control
Modify record number
modify
state
Amend page number and clause
Modifier
Auditor
Approver
modification date
Catalog
1. purpose
2. scope of application
3. terms and abbreviations
4. specification content
4.1 designation and writing of identifiers
4.2 note rules
4.3 indent rules
1. purpose
Good programming style is a very important means to improve the reliability of programs, and is also the technical basis for the cooperation and development of large-scale projects. The purpose of this specification is to avoid bad programming styles by standardizing definitions, and to enhance readability of programs so that they can understand other programmers.
2. scope of application
This provision applies to all software source code preparation. When customers have special requirements, they comply with the requirements of customers. For porting development or low release upgrade development, follow the format requirements of the previous version.
3. terms and abbreviations
This procedure uses the terms and abbreviations in the NQ402100 quality manual and their definitions.
4. specification content
4.1 identifier naming and writing rules
4.1.1 basic rules
1) here refers to the object identifier syntax in a programming language name, they have constant names, variable names, function names, and the type name, file name, basic syntax identifier is start with a letter, alphanumeric and underlined words.
2) the identifier itself is best able to indicate its own meaning for ease of use and for others to read. Consisting of one or more words in its meaning in application. It can be an English word or a Chinese phonetic word.
3) when the identifier consists of multiple words, the first letter of each word is capitalized, all the others are lowercase, and the constant identifiers are all capitalized. The first phonetic alphabet of each Chinese character described in chinese. English words are not abbreviated as far as possible. If there is an abbreviation, the same expressions must be used in the same system in the same system.
4) the total length of the logo should not exceed 32 characters.
4.1.2 special Convention
Some programming tools or project development teams have their own rules for naming identifiers, for example, the identifier is divided into two parts:
Standard Identifier prefix + meaning identifier
1) specification identifies the prefix used to indicate the identity of the classification features, and other types of identification to differentiate, for example: the prefix string variable identifier for STR, a string variable named strExample; prefix text box object identifier for the txt, a text box named object: txtExample;
2) the meaning identifier is used to indicate that the identifier corresponds to the abstract entity for memory,
In the example above, the "Example" of "strExample" is the meaning identification. Programming tools or project development teams have special agreements, subject to their agreement.
4.1. 3 source code, file identifier, naming rule
The source file identifier is divided into two parts, that is, the file name, prefix, and suffix. The format and rules are as follows:
* * * * * * * * * *
1) the prefix section is usually associated with the content or function represented by the document. A unified agreement can be made by the project team members.
2) suffix part usually represents the type of the file, you can give yourself, the specific programming environment has special provisions, in accordance with the programming environment.
3) prefixes and suffixes should use only letters, numbers, and underscores in these two parts. The length of the file identifier must not exceed 32 characters for identification.
4.2 notes and formatting requirements
Annotations are always added to the needs of a program, a general description, or an ill understood or easily understood error. Annotations should be concise, easy to understand and accurate, and the preferred language is Chinese. If you have input difficulties, compile environment restrictions or special requirements, you can also use english.
4.2.1 source code file comments
1) in the head of the document, you must mark the name of the program and the main functions it has completed.
2) the author of the document and the time it takes to complete it.
3) after the end of the phase test, the main modifications to the activities, people, time, simple reason list.
4) when the procedure needs to be modified during the maintenance process, the modification time and explanation should be indicated in front of the modified statement.
The annotation of a function or process of 4.2.2
1) in the function head, the function and parameter (value, parameter, parameter) of the function must be explained;
2) in the main part of a function, such as the algorithm is complex, it should be annotated to explain its algorithm structure;
3) functions that have applied global resources and may cause resource tensions should be annotated (e.g., memory, file handles, etc.);
4) function has side effects, must be marked in a very eye-catching way (such as add, number, etc.) noted;
5) the length of the function is within the 100 statement line (excluding comments), and when the program has special requirements (such as speed requirements, etc.), exceptions can be made.
Comments for the 4.2.3 statement
1) add notes to difficult branching conditional expressions;
2) a cycle that is difficult to understand should specify the exit conditions (procedures for GOTO should also specify inlet conditions);
3) too long function realization, should its statement according to the realization of functional segmentation to general description;
4) functions that are invoked by other files or functions, never use global variables to exchange data.
4.2.4 constants and variables are annotated
After the declaration of a macro in a constant name (or macro in a language of a macro mechanism), the name should be properly annotated, and the main point of the note is:
1) the meaning of the value to be saved (necessary);
2) the range of legal values (optional);
3) the global quantity needs to be fully explained by the point by point.
4.3 indent rules
Indentation of the 4.3.1 control structure
The program should display the block structure and control structure of the program in indented form, and reduce the
indentation level as much as possible without affecting the
display program structure. Use one of the following two
indentation methods:
1)
2)
If (expression)
{
声明
}
其他的
{
声明
}
如果(表达式){
声明
}
别的{
声明
}
4.3.2缩进的限制
一个程序的宽度如果超出页宽或屏宽,这将是很难读的,所以本规范要求使用折行缩进的方法、合并表达式或编写子程序的方法来限制程序的宽度。
1)任何一个程序最大行宽不得超过80列,超过者应折行
书
关于书的成语关于读书的排比句社区图书漂流公约怎么写关于读书的小报汉书pdf
写。
2)建议一个函数的缩进不得超过5级,超过者应将其子块写为子函数;
3)算法或程序本身的特性有特殊要求时,可以超过5级。
计算机源代码编写规范ver2.1 P-2 / 6
沈阳东大阿尔派软件股份有限公司
计算机源代码编写规范ver2.1 P-4 / 6
沈阳东大阿尔派软件股份有限公司