This specification mainly provides rules and precautions that the Delphi source program should follow during the writing process. The purpose of writing this specification is to keep the source code of the company software developers. Doing so allows each group of members to understand the code of other group members so that the maintenance of the secondary development memory system of the source code.
2. General format specification
2.1 indent
The indentation is two spaces exposed by increasing readability when changing the position of the source program. The indented rules are indented to two spaces per level. Not allowed to use Tab. Because Tab will produce different results due to the settings made by the user. When you encounter Begin or enter judgment, cycle, abnormal processing, WITH statement, record type declaration, class declaration, etc., when you encounter END or exit judgment, loop, exception handling, WITH sentence, record type declaration, Time to decrease the level when the class declaration is equal. E.g:
IF TMPINT <> 100 THEN
TMPINT: = 100;
2.2 Begin..nd
The begin statement and the end statement must be exclusive in the source program, for example:
For i: = 0 to 10 do begin // incorrect usage
END;
For i: = 0 to 10 do // correct usage
Begin
END;
2.3 spaces
Add spaces to both ends of operators and logic judging symbols, for example: i: = i 1;, A and B, etc., but no space is required when adding parentheses. For example: if (a> b) THEN / / error usage
IF (a> b) THEN // correct usage
Another example: Procedure Test (param1: integer; param3: string);
3. Object Pascal syntax writing format specification
3.1 Reserved Word
The reserved word or keyword of the Object Pascal language should be used in lowercase letters.
3.2 Processes and functions
3.2.1 Named and Format
The names of the process and function should be composed of meaningful words, and the first letter of all words should use uppercase letters. E.g:
Procedure formatharddisk; // incorrect naming
Procedure formatharddisk; // correct naming
Setting the process and functions of the variable content, you should use the set as a prefix, for example:
Procedure setusername;
The processes and functions of the read variable content should be used as a prefix, for example:
Function GetUsername: String;
3.2.2 Parameters of Processes and Functions
3.2.2.1 Named
The unified type of parameters are written in the same sentence:
Procedure Foo (Param1, Param2, Param3: Integer; Param4: String);
3.2.2.2 Named
All parameters must be meaningful; and when the parameter name and other attribute name are heavy, add a prefix 'A', for example:
Procedure SomeProc (AUSERNAME: STRING; aUSERAGE: Integer);
3.2.2.3 Name conflict
When the two Unit uses a rename function or process, when you reference this function or process, the function or process in the Unit declared in the USE clause is executed. To avoid this 'Uses-Clause-Dependent' needs to write full functions or processes in the reference function or procedure. E.g:
SYSUTILS.FINDCLOSE (SR);
Windows.FindClose (Handle);
3.3 variables
3.3.1 Variable Names and Formats
First of all, all variables must have meaningful names, so that other members can easily read the meaning representative of variables, and variable naming can use synonymous English name, you can use several English words, but the first letter of each word must capital. E.g:
VAR
WriteFormat :: string; at the same time for some specific types, certain simultaneous writes are as follows:
Pointer type
P
Record type
REC
Array type
Arr
class
Class
Cyclic control variables typically use single characters such as: I, J, or K. Also use a meaningful name, for example: UserIndex is also permitted.
3.3.2 Local variables
Use local variables in the process to follow naming rules for all other variables.
3.3.3 Global variables
Try not to use global variables, if you have to use global variables, you must add 'g', and you should reflect the type of variables in the variable name. E.g:
GPRECUSERCOUNT: POINT; // Name is the global variable of UserCount, which is a pointer to a structure.
However, global variables can be used inside the module. The global variable in all modules must be prefixed with 'f'. If you need to exchange between several modules, you need to be implemented by a method of declaring properties. E.g:
Type
TFORMOVERDRAFTRETURN = Class (TFORM)
Private
{Private Declarations}
FUSERNAME: STRING;
FuserCount: Integer;
Procedure setUsername (value: string);
Function GetUsername: String;
public
{Public declarations}
Property Username: String Read GetUsername Write setUsername
Property UserCount: Integer Read FuserCount Write FuserCount;
END;
3.4 Type
3.4.1 Calculation Protocol
The type name of the reserved word must be written. The type of Win32 API is usually all uppercase. For other types of first letters, the remaining letters lowercase, for example:
VAR
MyString: String; // Reserved Word
WindowHandle: hWnd; // Win32 API TYPE
I: integer; // type Identifier Introducesd in System Unit
3.4.2 Floating point type
Try not to use the REAL type, he is just compatible with the old Pascal code, try to use the Double type. The Double type is optimized to the processor and data bus and is the standard data structure defined by the IEEE. When the value exceeds the range of Double, use extended. But Extended is not supported by Jave. But use Single types when using other languages.
3.4.3 Enumeration Type
The name of the enumerated type must be meaningful and the name of the name is prefixed before. The name of the content of the enumerated type must contain a short-written name of the enumerated type name, for example:
TsongType = (Strock, StClassical, StCountry, Stalternative, Stheavymetal, STRB);
3.4.4 Array Type
The name of the array type must be meaningful and the name of the name is prefixed before. If a pointer to an array type must be prefixed before the name of this type, for example:
Type
PcycleArray = ^ TcycleArray;
TcycleArray = array [1..100] of integer;
3.4.5 Recording Type
The name of the record type must be meaningful and the name of the name is previously prefixed. If a pointer to an array type must be prefixed before the name of this type, for example:
Type
PEMPLOYEE = ^ Temployee;
Temployee = RecordemPloyeename: String
Employeeerate: Double;
END;
3.5 class
3.5.1 Named and Format
The name of the class must be meaningful and the name of the name is prefixed to add 't'. E.g:
Type
TCUSTOMER = Class (TOBJECT)
The name of the class instance is usually the name of the class of 't'. E.g:
VAR
Customer: tcustom;
3.5.2 variables in classes
3.5.2.1 Named and Format
The name of the class must make sense and the name of the name is prefixed to add 'f'. All variables must be four. If you need to access this variable from the outside, you need to declare an attribute.
3.5.3 Method
3.5.3.1 Named and Format
Named and format of functions and processes.
3.5.3.2 Attribute Access Method
All attribute access methods must appear in the private or protected. The name of the attribute access method is named after the function and process of the process, and the prefix 'Get' must be used with the write method (Writer Method) must use the prefix 'SET'. The parameters of the write method must be named 'Value', which is consistent with the attribute you want. E.g:
TsomeClass = Class (TOBJECT)
Private
Fsomefield: integer;
protected
Function GetSomefield: integer;
Procedure setsomefield (value: integer);
public
Property Somefield: Integer Read Getsomefield Write Setsomefield;
END;
3.6 Properties
3.6.1 Names and Formats
The name of the variable of the class of the class of the class with the same manner is consistent.
3.7 file
3.7.1 project file
3.7.1.1 Project Directory Structure
Program main directory - BIN (the path where the application)
-Db (path where the local database is located)
-DOC (where the document is located)
-HLP (the path where the help file is located)
-Backup (backup path)
-TMP (temporary file path)
3.7.1.2 Named
The project file must use a meaningful name. For example: project files for system information in Delphi are named sysinfo.dpr.
3.7.2 FORM file
3.7.2.1 Name
Consistent with the name of the Form: For example: The name of the FormMain is formmain.frm.
3.7.3 Data Module file
3.7.3.1 Named
The name of the Data Module file should make sense, and the 'DM' is used as a prefix. For example: User Data Module is named 'DMCUSTOMERS.DFM'.
3.7.4 Remote Data Module file
3.7.4.1 Named
The naming of the Remote Data Module file should make sense and use 'RDM' as a prefix. For example: User Remote Data Module is named 'RDMCUSTOMERS.DFM'.
3.7.5 Unit file
3.7.5.1 Ordinary Unit
3.7.5.1.1 Unit file naming
The naming of the Unit file should make sense and use 'unit' as a prefix. For example: General Unit is named 'UnitGeneral'.
3.7.5.2 Form Units
3.7.5.2.1 Named
The name of the Form Unit file must be consistent with the name of the Form. For example: The main form is called formmain.pas, the name of the Form Unit file is: UnitFormMain.
3.7.5.3 Data Module Units3.7.5.3.1 Named
The name of the Data Module Unit file must be consistent with the name of Data Module. For example: The main Data Module called Dmmain.pas The name of the Data Module Unit file is: UnitdmMain.
3.7.5.4 file header
The use of this file should be written on all files, the author, date, and inputs and outputs are written. E.g:
{
Modify date:
Author:
use:
This module structure consists of:
}
3.7.6 Forms and Data Modules Forms
3.7.6.1 Form class
1. FORM class naming standard
The naming of the Forms class should make sense and use 'tform' as a prefix. For example, the name of the About Form class is:
Taboutform = Class (TFORM)
The name of the main form is
TMAINFORM = Class (TFORM)
2. Naming standard for FORM class instance
The name of the form class instance should be the same as the name of the 't''s FORM class. E.g:
TYPE NAME
Instance name
Taboutform
Aboutform
TMAINFORM
Mainform
TCUSTOMERENTRYFORM
CustomERENTRYFORM
3.7.6.2 Data Modules Form
3.7.6.2.1. Data Module Form Name Standard
The name of the Data Modules Forms class should make sense and use 'TDM' as a prefix. E.g:
TDMCUSTOMER = Class (TDataModule)
TDMORDERS = Class (TDATAModule)
3.7.6.2.2. Data Module Instance Name Standard
The name of the class instance of the Data Module Form should be the same as the name of the 'T' Data Module Form class. E.g:
TYPE NAME
Instance name
TCUSTOMERDATAMODULE
CustomerDataModule
TordersDataModule
ORDERSDATAMODULE
3.8 control
3.8.1 Naming of the control instance
The example of the control should be used to remove the name of the 't' that control class as a prefix, for example:
Enter the name of the TEDIT of the user name: editusername.
3.8.2 Shorthand of control
The name of the control can use the following shorthand, but the drug is simply added to the control name between the '_':
3.8.2.1 Standard Tab
MM TmainMenu
PM TPopupmenu
Mmi TmainMenuItem
PMI TPopupMenuItem
LBL TLABEL
EDT TEDIT
MEM TMEMO
BTN TBUTTON
CB Tcheckbox
RB Tradiobutton
LB TListBox
CB TcomboBox
SCB Tscrollbar
GB TGroupBox
RG TradioGroup
PNL TPANEL
CL TcommandList
3.8.2.2 Additional Tab
BBTN TbitBTN
SB TspeedButton
Me tmaskedit
SG TSTRINGGRID
DG TDRAWGRID
IMG TIMAGE
SHP TSHAPE
BVL TBevel
SBX Tscrollbox
CLB Tchecklistbox
SPL TSPLITTER
StX TSTATICText
CHT TCHART
3.8.2.3 Win32 Tab
TBC TTABControl
PGC TPAGECONTROLIL TIMAGELIST
Re TrichEdit
TBR TTRACKBAR
PRB TPROGRESSBAR
UD tupdown
HK THOTKEY
Ani tanimate
DTP TDATETIMEPICKER
TV TTREEVIEW
LV TLISTVIEW
HDR THEADERCONTROL
STB TSTATUSBAR
TLB TTOOLBAR
CLB TCOOLBAR
3.8.2.4 SYSTEM TAB
TM TTIMER
PB TPaintBox
MP TMEDIAPLAYER
OLEC TOLECONTAINER
DDCC TDDECLIENTCONV
DDCI TDDeclientItem
DDSC TDDeServerConv
DDSI TDDeServerItem
3.8.2.5 Internet Tab
CSK TclientSocket
SSK TSERVERSOCKET
WBD TWEBDISPATCHER
PP TPAGEPRODUCER
TP TQueryTableProducer
DSTP TDataSetTableProducer
NMDT TNMDAYTIME
NEC TNMecho
NF TNMFinger
NFTP TNMFTP
NHTTP TNMHTP
NMSG TNMMSG
NMSG TNMMSGServ
NNTP TNMNNTP
NPOP TNMPOP3
Nuup TNMUUUPROCESSOR
SMTP TNMSMTP
NST TNMSTRM
NSTS TNMSTRMSERV
NTM TNMTIME
NUDP TNMUDP
PSK TPOWERSOCK
NGS TNMGENERALRERVER
HTML THTML
URL TNMURL
SML TSIMPLEMAIL
3.8.2.6 Data Access Tab
DS TDataSource
TBL TTABLE
Qry TQuery
SP TSToredProc
DB TDATABASE
SSN TSession
BM TBATCHMOVE
USQL TUPDATESQL
3.8.2.7 Data Controls Tab
DBG TDBGRID
DBN TDBNAVIGATOR
DBT TDBText
Dbe Tdbedit
DBM TDBMEMO
DBI TDBIMAGE
DBLB TDBListbox
DBCB TDBCOMBOBOX
DBCH TDBCHECKBOX
DBRG TDBRADIOGROUP
DBLL TDBLOOKUPLISTBOX
DBLC TDBLOOKUPCOMBOX
DBRE TDBRICHEDIT
DBCG TDBCTRLGRID
DBCH TDBCHART
3.8.2.8 Decision Cube Tab
DCB TDecisioncube
DCQ TDecisionQuery
DCS TDECISISOURCE
DCP TDECISIONPIVOT
DCG TDECISIONGRID
Dcgr TDecisiongraph
3.8.2.9 QReport Tab
QR TQUickReport
QRSD TQRSUBDetail
QRB TQRBAND
Qrcb TQRCHildband
QRG TQRGROUP
Qrl Tqrlabel
QRT TQRText
QRE TQREXPR
QRS TQrsysdata
QRM TQRMEMO
Qrrt tqrrichtext
QrDR TQRDBRICHText
QRSH TQRSHAPE
QRI TQRIMAGE
QrDi Tqrdbmimage
Qrcr TqrcompositerEport
Qrp tqrpreview
Qrch TQRCHART
3.8.2.10 Dialogs Tab
OpenDialog Topendialog
Savedialog TsaveDialog
OpenPictureDialog TopenPictureDialog
SavePictureDialog TsavePictureDialog
FontDialog TfontDialog
Colordialog Tcolordialog
PrintDialog TPrintDialog
PrinterSetupDialog TPrintSetupDialog
FindDialog TfindDialog
ReplaceDialog TreplaceDialog
3.8.2.11 Win31 Tab
DBLL TDBLOOKUPLIST
DBLC TDBLOOKUPCOMBO
TS TTABSET
Ol Toutline
TNB TTABBEDNOTEBOOK
NB TNOTEBOOK
HDR THEADER
FLB TFileListbox
DLB TDIRECTORYLISTBOX
DCB TDRIVECOMBOBOX
FCB TFilterComboBox
3.8.2.12 Samples Tab
GG TGAUGE
CG Tcolorgrid
SPB TspinButton
SPE TSPINEDIT
DOL TDIRECTORYOUTLINE
Cal Tcalendar
Ibea Tibeventalerter
3.8.2.13 ActiveX Tab
CFX TCHARTFX
VSP TVSSPELL
F1b TF1BOOK
VTC TVTCHART
GRP TGRAPH
3.8.2.14 Midas Tab
PRV TPROVIDER
CDS TclientDataSet
QCDS TQueryClientDataSet
DCOM TDCOMCONNECTION
Olee toleEnterpriseConnection
SCK TSOCKETCONNECONNECTION
RMS TREMOTSERVER
Mid TmidasConnection
4. Modification specification
The provisions made in this rule apply only to programs that have been included in configuration management. In such modifications, the content pre-modified and identifies the modifications and new content. And the necessary information such as the file header is added to the modification, modify the date, modify the description.
4.1 Modify history
When the source file is approved, the modifier shall add the modified historical item in the program file header. When each modification later, the modifier must fill in the following information in the project:
Modify
Change the time
Modify reason
How to modify the description
4.2 New Code Row
There should be a note before and after the new code row.
// Modify people, modify the time, modify the instructions
Add code line
// End of modification
4.3 Delete Code Row
Delete the front and rear of the code row instructions.
// Modify people, modify the time, modify the instructions
// The code row to be deleted (notes the statement to be deleted)
// End of modification
4.4 Modifying the code line
Modify the code line to delete the code line after the new code row.
// Modify people, modify the time, modify the instructions
// Code row before modify
// End of modification
// Modified code line
Modified code line
// End of modification