Delphi programmer code writing standard guide (4)

zhaozj2021-02-17  50

Four, documents

4.1 Engineering Document

4.1.1 Name

The project document should take a descriptive name. For example, the project name of the Delphi 4 Developer Guide Error Manager is: DDGBUGS.DPR. The name of a program related to system information should be like sysinfo.dpr.

4.2 Form file

4.2.1 Name

Name of a form file should be able to describe the purpose of using the form and suffix FRM. For example, a file name of a "about" form should be AboutFrm.dpr. The file name of the main form should be mainfrm.dpr.

4.3 Data Template File

4.3.1 Name

The name of the data template should be able to represent the purpose of using the data template, and its name should be added two characters of the suffix DM. For example, the file name of the custom data template should be CUSTOMERSDM.DFM.

4.4 remote data template file

4.4.1 Name

The name of the remote data template should be able to represent the purpose of using the remote data template, and its name should be the suffix RDM of three characters. For example, the file name of the custom distal data template should be CustomersRDM.DFM.

4.5 Unit file

4.5.1 Universal Unit Structure

4.5.1.1 Name of Unit

A Unit file should take a descriptive name. For example, the unit containing the application main form should be called mainfrm.pas.

4.5.1.2 Uses clause

The USES clause at the interface section should be included in the unit required in the interface section. Remove those Delphi to automatically join the unit in the program.

The USES clause in the Implementation section should only contain the name of the unit required for the code required in the IMplementation section. Remove unnecessary units.

4.5.1.3 Interface section

The Interface section should contain only those definitions, variables, process / functions of the access types that other units, and the like. Otherwise, it should be placed on the Implementation section.

4.5.1.4 Part IMPLEMENTATION section

The Implementation section should contain those types definitions, variables, procedures / function definitions, etc. that only in this unit.

4.5.1.5 Initialization section

Do not put the time-long code in the Initialization section, which will cause the first interface of the program.

It has a slower.

4.5.1.6 Finalization section

Here you must ensure that you release any resource you assigned to the Initialization section.

4.5.2 Form Unit

4.5.2.1 Name

The unit file of a form should have the same name as the form file it corresponds. For example, the unit name of the "About" form should be AboutFrm.PAS, while the unit name of the main form should be Mainfrm.PAS.

4.5.3 Data Template Unit

4.5.3.1 Name

The unit file of a data template should have the same name as the data template file it corresponds. For example, the name of a custom data template unit should be Customersdm.PAS.

4.5.4 General destination unit

4.5.4.1 Named

The name of the general purpose unit should meet the purpose of using the unit. For example, a utility unit is named bugutilities.pas. A unit containing global variables is named Customerglobals.PAS.

Note that the name of the unit cannot be the same as the name of the unit in all packets used in its work. Not approved with general or universal unit names.

4.5.5 Component Unit

4.5.5.1 Name

The component unit should be placed in a separate catalog to distinguish them in distinguishing between units or components set. They should always be in different directories. The unit name should be consistent with their content.

Note: Check the "User-Defined Component" section to get more information about component naming standards.

4.6 file header

It is recommended to use an information file header in all source files, project files, units, and the like. A good file header should contain the following information:

{

Copyright ... the year, month, day ...

}

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

New Post(0)