Main > Knowledge Base > Best practices > Code conventions > Module formatting > Rules of naming variables > Best practices > Code conventions > Module formatting > Rules of naming variables > Best practices > Code conventions > Module formatting > Rules of naming variables

Rules of naming variables

2023_02_dn-com_баннер на сайт_880х164.png

This article describes the standards that apply to variable names. All of the listed recommendations are mandatory unless noted otherwise.

1. Name your variables based on the terms of the subject area, so that the variable name clearly describes its purpose.

2. Create variable names by deleting spaces that separate the words. Capitalize each word in the name, including prepositions and pronouns that consist of a single letter.

Example:

Variable DirectoryProcessingDialog; // Dialog to work with a directory
Variable PacksInBoxQuantity; // Number of packs in a box

Examples of incorrect variable names:

maxAttributes, matchTypeName, newStr

3. Do not begin variable names with an underscore.

4. Do not use variable names that consist of a single character. Short variable names are only allowed for loop counters.

5. Name variables that describe binary states ("true" or "false") after the state that matches the "true" value.

Example:

Variable HasErrors; // Shows whether procedure contains errors.
Variable IsReusableContainer; // Shows whether a product is a reusable container.
Next page: Writing register records


See also:




© 1C LLC. All rights reserved
1C Company respects the privacy of our customers and visitors
to our Web-site.