Delphi Code Standard - Component Name

zhaozj2021-02-16  53

Component named

1. Naming standard for component type: The naming of components is similar to the name of the class, but it has 3 characters prefix. These prefixes are used to identify companies, individuals, or other entities. (Note that three characters as a prefix should be lowercase.)

For example, a clock component can declare this:

TLXSCHOOL = Class (Tcomponent)

2. Component Unit: The component unit can only contain one primary component, which is the component that is now on the component tab. Other auxiliary components or objects can also be included in the same unit.

3. Registration unit: The registration process of the component should be removed from the component unit and placed in a separate unit. This registration unit is used to register all components, attribute editing, component editing, wizard, and more. Component registration should be carried out in the design period. Therefore, the registration unit should be included in the design period rather than the running period. It is recommended to name the registration unit to name: XXXREG.PAS.

XXX is 3 characters prefixes to identify companies, individuals, or other entities.

For example: The registration unit in this book is named LXREG.PAS.

4 Naming Rules for Group Examples: The name of the component should have a descriptive. D e l P H i does not specify the default name for the component. The unit name is naming to use a changed Hungary naming specification. In this standard, the component name includes two parts: prefix and nature identification name.

(1) Component's prefix: The prefix of the component is the letter abbreviation of the expression type type.

E.g:

BTN: TBUTTON

EDT: TEDIT

SPDBTN: TSPEEDBUTTON

LSTBX: TiistBox

As shown above, the component type prefix is ​​made up of the component type name. The following rule illustrates how to define a component type prefix:

1) Remove the T preruption from the component type name.

For example: TButton becomes Button.

2) In addition to the first vowel, delete all the vowel letters.

For example: Button becomes bttn, and Edit becomes an EDT.

3) Compress the double letter.

For example: BTTN becomes btn.

4) If a conflict occurs, a vowel is added to a component prefix.

For example: adding a vowel to BATN in the prefix of the TBATton component to distinguish between the prefix of TButton.

(2) Component Nature ID Name: Component Nature Identification Name is a description of the components intent.

For example: a TBUTTON component for a new form can be named btnnewform.

An editing student's component can be named edtstudent.

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

New Post(0)