1.1. Formal parameter naming recommendations
The name of all formal parameters should be used to express its purpose. If appropriate, the name of the formal parameter should preferably be prefixed with the letter A, for example:
Procedure Someproc (ausername:string; auserage:integer);
Prefix A is necessary when the parameter name has the same name as the attribute or field of the class.
1.2. Naming conflicts
When a procedure with the same name in two cells is called, the procedure that is actually called is the one that appears later in the uses clause. To avoid this scenario, add the desired cell name to the method name
Sysutils.findclose (SR); or Windows.findclose (Handle);
1.3. Local variables, depending on the data type, should be identified with different prefixes, and each type of prefix corresponds to the following relationship:
Variable type |
Prefix |
Example |
Integer variable |
lowercase I |
ICount |
Shortint variable |
Lowercase si |
Sicount |
Cardinal variable |
Lowercase ci |
Cicount |
Longint variable |
lowercase L |
Lentrustno |
Int64 variable |
lowercase i64 |
I64serialno |
BYTE variable |
Lowercase BT |
Btflag |
Word variables |
lowercase W |
Wcount |
DWORD variable |
Lowercase DW |
Dwcount |
Boolean variable |
Lowercase b |
Bfound |
Char variable |
lowercase C |
Ckind |
String variable |
lowercase s |
SName |
Float variable |
lowercase E |
Elastprice |
Double variable |
lowercase E |
Ecurrentbalance |
Handle variable |
Lowercase h |
Hdllhandle |
Pchar variable |
Lower case SZ |
Szbuffer |
X-coordinate |
lowercase x |
XPos |
Y-coordinate |
Lowercase y |
YPos |
1.4. Global variables usually begin with the capital letter "G" and follow the naming conventions of other variables.
1.5. Enumeration type
The enumeration type name represents the purpose of the American drama, preceded by a T character prefixed by the name, indicating that this is a data type. The prefix of an enumeration type's identifier list should contain 2-3 lowercase characters, and small shoes are rich in the generic type name of each word path, example
Tsongtype= (Strock, stclassical, Stcountry, Stalternative, Stheavymetal, StRB);
The name of a variable instance of an enumeration type is the same as the type, but without the prefix T, you can give the variable a more special name, such as: Goodsongtype, Badsongtype, and so on.
1.6. Array type
The array type name should express the purpose of the array. The type name must be prefixed with the letter "T". If you want to declare a pointer to an array type, you must prefix the letter P and declare it before the type declaration. Cases
Type Pcyclearray = ^tcyclearray; Pcyclearray is a pointer of type Tcyclearray tcyclearray=array[1..100] of integer; Var Cyclearray:tcyclearray; In fact, the variable instance of the array type is the same as the type name but does not have a "T" prefix
1.7. Record type
The record type name should express the purpose of the record. The type name must be prefixed with the letter T . If you want to declare a reference to a record type, you must prefix the letter P and declare it before the type declaration. Example
Type pemployee = ^temployee; Temployee = record employeename:string; employeerate:double; End
1.8. Class type
The name of the class should express the purpose of the class. The general class name to add the letter "T", if it is an interface class before the class name to add "I", the class name of the error exception class to add "E", and the class reference type ( class-reference type) add "Class" To the class name, and the abstract class is usually added "Custom" before the class name.
The instance name of the class is usually the same as the class name, except that there is no prefix "T".
1.9. member variables of a class
The name of a member variable of a class follows the same rules as the variable, except that it is prefixed with F, which indicates that this is a member of the class.
All member variables must be private. If you want to access a field outside the scope of the class, you can do so by using the properties of the class.
1.10. Property access Methods
All property access methods should be defined in the private or protected section of the class. Property access methods follow the same rules as procedures and functions. The method used for reading should be prefixed with a "Get", and the method used for writing should be prefixed with a "Set", and there is a parameter called value, whose type is the same as the type of the property. For example:
Tsomeclass = Class (TObject) private fsomefield:integer;protected function Getsomefield:integer; Procedure Setsomefield (Value:integer);p ublic property Somefield:integer Read Getsomefield write Setsomefield;end ;
1.11. Properties
property as an accessor to a member variable, followed by the same naming convention as the member variable, except for the F prefix. The attribute name should be a noun, not a verb. Properties are data, and methods are actions. The array property name should be a complex number, and the general attribute should be singular.
1.12. Component instance naming
The name of the component instance should be able to describe its actual meaning. The reason for using prefixes instead of suffixes is that searching for a widget's name in the object Inspector and the Code Explorer is easier than searching for the type of the artifact. In this standard, the component instance name consists of two parts: a prefix and a property identifier name.
1.13. Prefixes for components
A component's prefix is mostly a letter abbreviation that displays the component type. See the component prefixes in the following table:
Component Class name |
Component prefixes |
Tactionlist, taction The list item that represents the action |
Act |
TButton, Tspeedbutton, tbitbtn and other button classes |
Btn |
Tcheckbox, Tdbcheckbox and all the check boxes |
Chk |
Tradiobutton radio Button class |
Rdo |
Ttoolbar Tool Bar |
Tb |
Tmainmenu All the main menu classes |
Mm |
Tmainmenuitem all the menu item classes |
Mi |
Tpopupmenu all pop-up menu classes |
Pm |
Tpopupmenuitem all pop-up menu item Classes |
Pmi |
Tlabel, Tstatictext, etc. all label classes used for display |
LbL |
All panel classes such as Tpanel |
PnL |
All page-type control classes such as Tpagecontrol |
Pgc |
Tedit, Tmaskedit, etc. all single-line edit box class |
EDT |
TMemo, Trichedit, etc. all multi-line edit box class |
Mmo |
Tdrawgrid, Tstringgrid, etc. all grid classes |
Grd |
All animation classes such as tanimate |
Ani |
Timagelist and so on all the picture List class |
Il |
Timage and other picture classes |
Img |
Tchart Chart Class |
Cht |
Tcombobox, Tdbcombobox, and all drop-down list box classes |
Cbo |
Tlistbox, tdblist, etc. all list box classes |
Lst |
Ttreeview |
Tv |
TListView |
Lv |
Thotkey |
hk |
all delimiter classes such as Tsplitter |
Spt |
All dialog box component classes such as Topendialog |
Dlg |
All data table classes such as ttable |
Tbl |
All SQL query class components such as tquery |
Qry |
TClientDataSet all customer data Set components |
Cds |
Tdatasource |
Ds |
Tdatabase |
Db |
Tsockconnection,tdcomconnection and other connecting component classes |
Con |
Tquickrep, Tfastreport, etc. all report component classes |
Rpt |
All DDE component classes such as Tddeclientconv,tddeclientitem |
Dde |
All calendar classes such as Tmonthcalendar |
Cal |
Tgroupbox and other control classes |
Grp |
Tform and other form classes |
frm |
as shown above, the component type prefix is from the analysis describing the type nature of the component. Typically, the following rules describe how to define a component type prefix:
- Remove the T prefix from the component type name . For example , TButton becomes a Button.
- In addition to the first vowel, delete all vowels. For example, theButton becomes bttnandEdit becomes EDT.
- Compresses two letters. For example,bttn becomes btn.
- In the event of a conflict, a vowel is added to a component prefix. For example, add a vowel to batnin the prefix of the Tbatton componentto differentiate TButton prefixes.
However, the above rules first ensure that the prefix name must conform to the custom, so that the name is known, such as: Tddeclientconv control prefix is an exception.
Note: The component prefix is to indicate the type of component, whether it is a button, a label, and so on, so it is not necessary to establish a component prefix for each special component class, such as: Tmybutton's component prefix is still btn.
1.14. naming standards for form types
The name of the form or dialog box type should express the purpose of the form, if it is the form to add "Tfrm" prefix, if the dialog box to add "tdlg", followed by a descriptive name
1.15. naming criteria for form instances
The name of the form instance is the same as the corresponding type name, but does not have a prefix T . The advantage of naming forms and dialogs using the prefix method is that you can quickly find the required component types in the Object Inspector (property observer)
1.16. Naming the Data modules
The Data module type name should express its purpose and be prefixed with "Tdm" followed by a descriptive name
1.17. Naming the Data module instance
The name of the data module instance should be the same as the corresponding type name, but without the prefix T
Of course, this is only part of it, and there are many norms that need to be developed and obeyed. In addition, this is only a proposed specification, is not a mandatory thing, according to their own team situation to specify standards and rules to meet their own
Specifications recommended by Delphi Programming 2---naming conventions