Name of author: wl3000wlnew
Reader Rating 10 Ratings 3
VC programming specification text - programmers should write code writers: wl3000wlnew 1.1 Basic requirements program structure clear analysis, easy to understand, single function of the number of program lines may not exceed 100 lines. 1.2 What is going to do, it is simple, directly when it is straight, and the code is streamlined, and the garbage program is avoided. 1.3 Try to use the standard library function and public functions. 1.4 Do not define global variables at will, try to use local variables. 1.5 Use parentheses to avoid amphibia. 2. Readability requirements 2.1 readability first, efficiency second. 2.2 Hold the comment is exactly the same as the code. 2.3 Each source file has a file header, indicating that the specification is specified. 2.4 Each function has a function head description, indicating that the specification is specified. 2.5 Main variables (structures, joints, class or objects) are defined or referenced, the comments can reflect their meaning. 2.7 Constant Definition (Define) has a corresponding description. 2.8 Each phase of the process has a related note instructions. 2.9 There is a comment before the typical algorithm. 2.10 Using the logical structure of the display program, the indentation volume is consistent, and the Tab is 6 bytes. 2.11 Circulation, the branch level should not exceed five layers. 2.12 Note You can be in the same row with the statement, or you can go up. 2.13 Blank Characters is also a special annotation. 2.14 At a glance, the statement does not comment. 2.15 The scope of the annotation can be: definition, reference, conditional branch, and a piece of code. 2.16 Note (not including the program head and function header) should account for 1/5 to 1/3 of the total number of lines. 3. Structured Requirements 3.1 No two equivalent branches are prohibited. 3.2 Prohibiting the goto statement. 3.3 Use the IF statement to emphasize only one of the two groups of statements. Do Else Goto and else return. 3.4 Use CASE to implement multiple branches. 3.5 Avoiding multiple exits from cycles. 3.6 The function has only one exit. 3.7 Do not use the condition assignment statement. 3.8 Avoid unnecessary branches. 3.9 Do not use the conditional branch to replace logic expressions. 4. The correctness and fault tolerance requirements 4.1 The program is first correct, followed by beautiful 4.2 Unable to prove that your program has no error, so after writing a program, you should first check. 4.3 Change an error may generate a new error, so the impact on other programs will be considered before modifying. 4.4 All variables must be initialized before calling. 4.5 Enter all user inputs must be checked. 4.6 Do not compare the equal number of floating point numbers, such as: 10.0 * 0.1 == 1.0, not reliable 4.7 Programs and environmental or status relationships, must actively deal with accidents, such as whether the file can be logically locked, whether the printer is online. 4.8 Unit test is also part of programming, and the procedure for submitting a joint test must pass through unit testing. 5. Reuse Requirements 5.1 Reusually Complete the relative independent function algorithm or code should be abstract as a common control or class. 5.2 Public controls or categories should consider OO ideas, reduce external contacts, consider independence or encapsulation. 5.3 Public controls or classes should establish a template. Attachment: C programming specification, Delphi makes the corresponding reference. 1 Scope This standard applies to people developed by using Visul C , Borland C ..
.2 variable naming name must have a certain actual meaning, form is Xabcfgh, X is determined by the variable type, ABC, FGH represents a consecutive string, if the consecutive string is only two, can be capitalized. Such as OK. Specific routine : Bool Type Benable; Ch * Char Chtextc * Class Object CMAIN (Object Example) H * Handle HWNDI * INTN * No Symbol Integer P * Pointer SZ, STR * String W Wordx, Y Coordinate Char or TCHAR Type Windows API has direct contact in the form of Szappname [10], otherwise in form, single characters can also be represented by lowercase letters; int type ncmdshow; long type lparam; uint type unotify; dWord type dWstart; PSTR type PSZtip; lpstr type lpCmdLineLPTSTR type lpszClassName; LPVOID type lpReservedWPARAM type wParam, LPARAM type lParamHWND type hDlg; HDC type hDC; hINSTANCE type hInstanceHANDLE type hInstance, HICON type hIcon; int iTmpfloat fTmpDWORD dw * String, AnsiString str * m_ class member variables m_nVal, m_bFlagg_ global variable g_nMsg The following general variables can be used in the g_bflag part variable: NTEMP, NRESULT, I, J (generally used for loop variables). Other resource sorts .3 constant naming and macro definition constants and macro definition must have a certain actual meaning; constant and macro definitions between #include and function definitions; constants and macro definition must be written in uppercase letters, the middle can be based on the continuity of meaning Connect with underline, each defined right side must have a simple annotation, explain its role; resource name definition format: menu: IDM_XX or cm_xx bitmap: IDB_XX dialog: IDD_XX string: IDS_XXDLGINIT: DIALOG_XXCON: IDR_XX.4 function Name Function prototype instructions include reference external functions and internal functions, external references must be indicated on the right side: module name and file name, such as internal functions, as long as you know its definition file name; the first letter must use uppercase letters, required to use Understanding alphanumeric composite specification function named, can be used in line intervals when necessary, examples are as follows: void updatedb_tfgd (track_name); // module name: r01 / sdw.cvoid printTrackData (TRACK_NAME); // Module Name: R04 / TERN.CVOID IMPORTANTANTPOINT Void); // module name: r01 / sdw.cvoid showchar (int, int, chtype); // local modulevoid scrollup_v (int, int); // local module.5 Structure Name Structure Type Names must be all written Letters, in principle, the above scribe is started; the structural variable naming must be combined with uppercase, the first letter must use uppercase letters, if necessary, it can be used in line intervals. For private data zones, the process thereof must be indicated. Global data definitions simply pay attention to their use.
Examples are as follows: typedef struct {char szProductName [20]; char szAuthor [20]; char szReleaseDate [16]; char szVersion [10]; unsigned long MaxTables; unsigned long UsedTables;} DBS_DATABASE; DBS_DATABASE GdataBase; named 6 controls: with Small write prefix indicates that category is in a lowercase prefix, a cob combo, drop-down list box txt text input box Labal, tag img image, image PIC PICTUREGRD GRID, Grid SCR scroll bar LST list box FRM FRAM7 annotation principle Note Requirements to use Chinese; file start annotation includes: company name, copyright, author name, time, module purpose, background introduction, etc., complex algorithms need to be added to process instructions; function comments include: input, output, function description, process Processing, global variables, call samples, etc., complex functions need to be added to variable purposes; annotations include: modification time and authors, easy-to-understand annotations, etc. *********************************************************** ************ File Name: ** Copyright (c) 1998-1999 ******** Company Technology Development Department ** Create: ** Date: ** Modify People: ** Date: ** Description: **** Version: ** -------------------------------- -------------------------------------------- ***** *********************************************************** ********** / Reference 2: Note Template with the beginning of the function / ********************************************** ************************************* Function Name: ** Enter: A, B, C ** a --- ** b --- ** c --- ** Output: x --- ** x is 1, indicating ... ** x is 0, indicating ... ** function description : ** global variables: ** calling module: * author: * date: * Review: * date: * * Version ********************************************************** **************** / Reference 3: Note Templates in the program / * --------------------- ----------------------------------- * // * comment content * // * ----- -------------------------------------------------- --- * / 8 Program a. Program coding strikes simple, clear structure, avoid too much branch structure and too much skillful procedures, try not to use recursive mode. b. When writing a program, you must also want to test the method. In other words, the test plan of "unit test" should be equated to write at the program. c. Note must be consistent with the program. d. Modifications after version storage must use the old statement to / * * / closed, unable to delete or modify itself, and record them in the modification record of the file and function. e. The beginning "{" and "}" of each block in the program must be aligned, nesting blocks, indented a Tab, Tab is 4 space, block type includes if, for, while, do, etc. Keywords are introduced.