Development standards
The 1C development standards — naming, module structure and automatic code checks.
5 questions
JuniorTheoryVery commonWhich rules of the 1C development standards for variable names do you know?
Which rules of the 1C development standards for variable names do you know?
By standard #454 a name is made of subject-area words, each capitalised: КоличествоПачекВКоробке. No type prefixes, leading _ or abbreviations; one-letter names only for loop counters; a boolean is named by its true value: ЕстьОшибки.
Common mistakes
- ✗Adding a type prefix such as
масorстр: the name says what the variable holds, not its type - ✗Shortening words, as in
КолТов: the standard asks for full words - ✗Naming a boolean after a check,
ПроверкаОшибок: it is named by its true value,ЕстьОшибки
Follow-up questions
- →How does the standard tell you to name a procedure and a function?
- →When is a one-letter variable name acceptable by the standard?
JuniorDebuggingCommonWhich line of this procedure breaks the 1C standards?
Which line of this procedure breaks the 1C standards?
Line 2: a boolean is compared with Истина
Common mistakes
- ✗Taking the direct assignment
ЕстьОшибки = Остаток < 0for a violation: the standards allow it and forbid the comparison withИстина - ✗Writing
Если Флаг = Истинаto make the condition clearer: the boolean already is the condition, and standard #441 forbids the comparison
Follow-up questions
- →How do you check that
ЕстьОшибкиis false without comparing it withЛожь? - →Which tool checks 1C code against the standards automatically?
JuniorTheoryCommonWhy does a 1C module need #Область regions, and which ones are standard?
Why does a 1C module need #Область regions, and which ones are standard?
Regions group code into named sections between #Область and #КонецОбласти and do not affect execution. Standard #455 sets their order: ОписаниеПеременных, ПрограммныйИнтерфейс, СлужебныйПрограммныйИнтерфейс, СлужебныеПроцедурыИФункции.
Common mistakes
- ✗Expecting
ПрограммныйИнтерфейсto export its methods:Экспортis still written on each one - ✗Leaving an empty region in a module: the standard asks to remove it
- ✗Treating regions as compile units: they only group the text
Follow-up questions
- →Which regions does a form module have besides the standard ones?
- →What belongs in
СлужебныйПрограммныйИнтерфейсrather than inПрограммныйИнтерфейс?
JuniorDebuggingCommonWhich name in this function breaks the 1C naming standard?
Which name in this function breaks the 1C naming standard?
масТоваров: the name starts with a data type prefix
Common mistakes
- ✗Expecting a boolean name to start with
Это: any name of the true value fits,ЕстьСкидкаincluded - ✗Putting a type prefix such as
масorстрbefore a name: standard #454 forbids them, a name says what the variable holds
Follow-up questions
- →How should a procedure that recalculates a discount be named by the 1C standards?
- →Which variables may have one-letter names under the standard?
MiddleTheoryCommonHow do you check 1C code against the development standards automatically?
How do you check 1C code against the development standards automatically?
With static analysers: «1С:Автоматизированная проверка конфигураций», the checks in 1С:EDT, or the open BSL Language Server, also used in SonarQube. They report naming, module structure and query-in-loop violations; run them in CI on every commit.
Common mistakes
- ✗Relying on the Designer's syntax check alone: it does not check naming or module structure
- ✗Running the analyser once before a release: violations pile up unless it runs on every commit
Follow-up questions
- →Which standard violations can a static analyser not detect reliably?
- →How do you bring an old configuration with thousands of findings under such a check?