Hippocampus software development specifications

zhaozj2021-02-08  213

Hippocampus software development specifications

Netizen hippike provides his coding specification, I think everyone should learn, if the netizen hippo does not agree, I will immediately delete this document.

Source Class Naming Regulations 1) General: The file name is all lowercase letters. The source file suffix is ​​.c or .cpp header file suffix is ​​.h. 2) In order to clearly define individual sub-modules, subsystems, it is recommended to use the following identifiers as the prefix of source files: Submapped: SMS_ Public File COM_ Communication section UIM_ User's DBA_ Database Access Test_ Test Program Communication Module Subside: PRC_ Process scheduling mechanism DLG_ session and transaction mechanism CFG_ configurable mechanism and configuration center subsystem WRK_ monitor alarm log mechanism DB_ database agent subsystem log_ log subsystem MON_ surveillance subsystem WARN_ alarm subsystem 3) file header declaration format file name: File name (EG: Add.c) Author: Author: Name (EG: Newton) Date: This file creates a date (EG: 2000/8/1) File function: The function can be implemented (EG: One of the Source) Files for the class CEDIT version: Release Number (EG: 1.0) Compile Environment: (EG: VC 6.0, GNU) Implementation Environment: (EG: Windows98, Helio 3.2) Note: Additional notes for files (including those functions And global variables) Modify Name (EG: Einstein) Modification (EG: 2000/9/1) Detail of the modified content ... Copyright statement: ------------ -------------------------------- (EG: CopyRight (C) 2000 Microsoft. Al Rights Reserved.). The provisions of classes and variables 1) Create two files (.c and .h files) as much as possible. Methods of prefix can be used to form a file name. Don't be afraid that the file name is too long. For each class, it is convenient for maintenance, easy to find, modify, and according to the class name, you can find the file name directly. Several classes that can be made with a small number and a small amount of code are not largely related. H / .C file. Publications can be placed together. 2) The name of the class (own defined) is started with uppercase. The name of the structure is started with ST. The name of the enumerated type is started with EN. The joint name is started with UNN. Customized simple data type begins with T. These prefixes follow the words starting with uppercase letters.

3) Declaration of variables: The name of the variable is capable of reflecting one or more lowercase letters of the variable or nature (according to Hungarian rules; Hungarian rules --- variable type is represented by one or two characters.) Some commonly used The representation is as follows: ----------------------------------------- Prefix | Data Type - ---------------------------------------- CHar D | Double S | String i INTEGER L | Long X, Y | Integer, LONG (when used as X, Y coordinates) CX, CY | Integer, long (used as X, Y length, respectively) B | BOOL P | Pointer ---- --------------------------------------- 4) Function (class member function can be outside ) And macro definitions, Note: The name of the function starts with uppercase words, using size words mixed, can use the commonly used abbreviation without using lowercase letters to decrease the underscore. The naming of the function should indicate its role, don't be afraid of the name long. Example: getMaxLength (); unless it is inside the function body, the original simple data type should not be used, it should reflect the data to reflect the data. The data type of the feature. The parameter type of the function should use the custom type as much as possible. The return value of the function uses the enumeration type as much as possible, or uses a custom type. Function header declaration format: Function Name: Function Name Date: This function creates a function function: This function can implement function parameter description: The input output parameter of the function, return value, and the global variable used for use ... Macro defined names are all uppercase letters. Do not try to use macro definition instead of the function. Macro is not too long. Pay attention to the integrity of parentheses when macros define. For the constant, expressions, etc., which are defined, and the expression, etc. must be enclosed in parentheses. For iconic values, or a value of several cases, you should use the enumeration type to define meaningful names or macro definitions, not intended. The name of the compilation symbol is below the underscore, and it is overlined with uppercase letters and underline. Write a comment while writing. Short annotations should be inspired and is useful to readers. If you write a comment when you write the code, not all the work is finished, and you can avoid many errors. For program head descriptions and function descriptions that do not want to spend time at the beginning, it is understandable, but there is always time to add a short annotation when writing code.

5) Naming: Principle: Name Attribute Names of Controls To indicate the type of control, the usage, the common constraints is as follows name = control name (lowercase prefix) use (the first letter of the word) ***** *********************************************************** ******* object prefix example **************************************** ******************************** FORM FRM FRM FRMFILEOPEN LABEL (Label) LBL LBLHELPMESAGE FRAME (Frame) FRM FRMLANGUAGE CHECKBOX (check box) Chk ChkReadonly ComboBox CBX CBX CBXENGLISH ListBox (list box) LST LSTPOLICYCODES TIMER (Timer) Timalarm Shape (Shape (Circle, Square ..)) SHP SHPCIRCLE Image (Note: Developers have not appeared in specifications The control should be reported to the encoding specification writer to determine its specification) 6) Naming: Main menu: Using the prefix MNU current menu title example: file -> mnufile submenu: Using the prefix MNU Current main menu title Current menu Title Example: Open ---> MnuFileOpen 6 under File, Programming Rules 1) First meet the requirements of software programming specifications and database norms. Programmaker must not change the design, if necessary, must notify the designer, and after the design person is approved, it can be changed. The classes involved in the design are not allowed to define the PUBLIC type function, or change the properties of the class function or member variable (Public, Protect, Private, Virtual). 2) Definition of global variables must be licensed by designers. You must use a simple global variable to define a small number of global objects. Global variables can be placed in a specialized class to access variables through the function interface. Variables (global, local) should also be initialized. 3) The destructuring function is usually declared as a virtual, otherwise it will be incorrectly destructed. For example: baseclass * pb = new childclass; ...; when Delete PB, if the BaseClass's destructor is not a virtual function, the childclass destructor is not called. If you do not declare the destructor as Virtual, you will give a comment and indicate the reason. As long as you specify the designer of the original base class as Virtual. You cannot use the copy constructor instead of the overloaded of the assignment operator. If there is a non-default constructor, you must redefine the default constructor. The virtual function cannot be the inline function. The constructor cannot be empty. The overload of the assignment operator is required as a member of the class. 4) The pointer must initialize and may not use a pointer that is not initialized or not assigned. It is time to determine if it is empty before using the pointer, and the pointer is set to empty.

It is recommended not to release the empty pointer (although on the system, the empty pointer is released without a bad consequence). The pointer is used in time to release. In general, within the destructuring function, the work of the release of the memory (release the dynamically assigned memory in the object operation) is performed. For the linked list, the next object's NEXT pointer must be set to empty. 5) Pay attention to an array of critical problems, be sure to determine the number of elements of the array. For a string of known lengths, the data type should be predefined, and then the custom type is used instead of using char *. Take a note of the string allocation space to pay attention to a one byte 6) Unless it is inside the function body, the original simple data type may not be used. It should be aware of various types of data definitions that make sense to reflect the data type of the data. 7) The return value of the function uses the enumeration type as much as possible, or uses a custom type. For iconic values, or a value of several cases, you should use the enumeration type to define meaningful names, not intended. The parameter type of the function should use the custom type as much as possible. 8) Definition of data types (including simple data types, common structures, excluding classes), placed in a unified public file (tentative SMS_DATATYPE), and must not define data types elsewhere. The benefits of a definite data type in public documents SMS_DATATYPE are for easy modifications, and there is a general understanding of the data of the system. 9) Do not rely on a specific subsystem, the definition of common functions used for multiple subsystems, placed in public files SMS_Pub.H and SMS_Pub.c. 10) The definition of the fundamental class and the public class is placed in the public file SMS_CLASS.H and SMS_CLASS.C. For classes that have been implemented in SMS_CLASS.H (.c), a class similar to it is not defined. For the same or similar functions, multiple classes must not be defined. 11) When the string pointer is functional parameters, pay attention to the difference between input and output parameters. At the same time, pay attention to whether the pointer itself can be modified. If you can modify the pointer, you should also pay attention to whether you want to redistribute the space. 12) Carefully use strcpy, do not use it as much as possible, you can use Strncpy or Memcpy instead (don't forget to add '/ 0' after the target string, you can customize a strcopy function, copy a certain number of characters, automatically in the target character Add '/ 0' after the string. Example: (Defined in File SMS_Pub.c) INT STRCOPY (PSTR DEST, PSTR SRC, UINT MAXLENGTH) {IF (! DEST ||! Src) Return -1; Strncpy (DEST, SRC, MAXLENGTH-1); DEST [MAXLENGTH-1] = 0; RETURN 0;} 13) When compared by ==, pay attention to place the constant or value in front, put the variables behind, to avoid errors == erupted into = errors. Try not to use string constants in error messages, prompt information, etc.. You can unify the string constant in a header file macro (defined in SMS_ERROR.H for all error types) to facilitate changing the locale. 14) Do not define a member function of the class in .h file (referring to the implementation of the function), but should be defined in .c or .cpp file. Only the structure of the class is defined in .h file, make a declaration of the members of the class. Use standard C as much as possible. Do not do any assumptions on the compiler, try to write code-independent code.

Because the system we developed needs to support multi-platform, portability is important. If you must use the code related to the platform, you should add a significant annotation, and use the compilation symbol to determine the specific platform. Copyright netizen hippocampus.

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

New Post(0)