1Ci Support Help Center home page
Submit a request
Sign in
  1. 1Ci Support
  2. 1C:Enterprise Development Standards
  3. Code conventions
  4. Module formatting

Module texts

  • Module formatting
    • Module texts
    • Module structure
    • Procedure and function names
    • Procedure and function description
    • Procedure and function parameters
    • Specifics of using structures as procedure and function parameters
    • Rules for variable names generation
    • Working with Cancel parameter in event handlers

Scope: managed applications, mobile applications, and ordinary applications.

$$$ 

$$$

$$$ $$$

$$$ $$$ $$$

1. Do not use non-breaking spaces and a minus sign in module texts in other encodings (en or em dash, and so on).

Usually these characters appear in module texts when copied from Microsoft Office documents and complicate the development process. For example, texts with minus signs or non-breaking spaces cannot be searched. Tooltips for procedure and function parameter types in Designer and extended check in 1C:EDT are displayed incorrectly. If you specify a minus sign in a form, a syntax error occurs.

Best practices

2. Modules cannot contain unused procedures and functions.

3. Modules cannot contain commented code snippets or snippets related to either development process (debug code, official notes such as TODO, MRG, and other) or the code developers. The following code snippets are not allowed once debugging or refactoring is complete:

Procedure BeforeDelete(Cancel)
//    If True Then
//        Message("For debugging");
//    EndIf;
EndProcedure

Another incorrect example:

Procedure BeforeDelete(Cancel)
    If True Then
        // Mr Smith: finish 
    EndIf;
EndProcedure

Correct: Once debugging or refactoring is complete, delete the BeforeDelete handler from the code.

4. Each module text operator begins on a new line. Two or more operators on a line are allowed only if these are assignment operators of the same type, for example:

InitialIndex = 0; Index = 0; Result = 0;

5. Module texts must be indented. To indent, use tab not spaces, so that whenever the number of digits in a tab changes, the text remains aligned.

Use the standard tab size (4 spaces).

5.1. You can start the following objects from the leftmost position:

  • Operators Pocedure, EndProcedure, Function, EndFunction 
  • Operators of predeclaration of procedures and functions 
  • Headers (details) of procedures and functions 
  • Module variables declarations 
  • Operators of the main application section (considering an indent)
  • &AtClient, &AtServer compilation directives and other
  • Preprocessor commands, including #Region and #EndRegion

5.2. BeginTransaction and CommitTransaction procedures are not statement brackets. Text inside these procedures is not shifted.

6. If there are more than 120 characters in a string, use line breaks. We do not recommended that you use strings with over 120 characters. An exception is when moving lines is impossible. For example, the code might contain a long string constant, which is displayed with no line breaks in the message dialog box using the UserMessage object.

See also: Line breaks in expressions.

7.1. Module texts can contain comments. Make sure your comments detail functionality of modules or operators. Your comments must be written in a formal language, be neutral and must not contain terms not related to the application functionality. 

7.2. Place short comments at the end of a string being commented, for example:

FoundErrors.Columns.Add("Number"); // for compatibility.

7.3. Place long comments or code snippet comments before the code being commented on a separate line. The text of the snippet being commented is left-aligned. Insert a space between slashes "//" and a comment.

// Initializing variables for calculations
// in the module text.
CurrentDate = Common.GetWorkingDate(); 
CurrentYear = Year(CurrentDate); 
CurrentMonth = Month(CurrentDate); 
CurrentWeek = WeekOfYear(CurrentDate); 
CurrentDay = Day(CurrentDate);

8. You can split texts of long procedures and functions into separate collapsible areas. Region names must comply with the requirements of the Naming variables standard.

To format the code automatically, use the attached data processor.

See also:

  • Rules of creating common modules
  • Module structure
© 2020 1C INTERNATIONAL LLC www.1Ci.com Support policy