From OpenSCADAWiki
Jump to: navigation, search

Rules for design and commenting of the sources of OpenSCADA and its modules

When writing and design of the sources of OpenSCADA and its modules you must to follow the rules:

  • indent between the levels of enclosure: 4 characters;
  • tabulation space: 8 symbols;
  • braces of opening placed in previous command place, if the shorter for 80 symbols;
  • braces of closing must be placed in separate lines at the level of the previous text;
  • it is possible to write an enclosure in the single line with the previous level of enclosure, in case of increasing the readability of the code;
  • distance between the descriptions of the functions of at least one character;
  • the distance between the definition of variables and the text of the program at least one symbol;
  • it is possible to define variables in the text while saving the readability;
  • to avoid long lines more than 100 characters;
  • preprocessor commands must be located on the first level, regardless of the current level of the text;
  • for the formatting the source code, inherited from the other free applications and examples, it is recommended to use the utility:
indent -bli0 -i4 -ts8 -l100 -npsl -npcs -nprs -nsaf -nsai -nsaw -brs -br -cdw -nbc -lp <filename>.