A distinction should be made between two types of comments:
- Block comments (these describe what a function or a code section does)
- Line comments (these describe the code of an individual line)
Recommendation:
A block comment should be located at the beginning of the corresponding code section. A line comment, if possible, should be located at the end of the code line – otherwise in front of the associated code line.
//Block comment that explains the next session of code
//It may be long and split into multiple lines to limit
//the number of columns
IF Condition THEN //Line comment explaining a single line
;
END_IF;
Rule:
Comments in ST start with //. The comment is started after the slash symbols without any blanks. Reason: For test purposes, complete blocks can be simply removed using (* *) or /* */.
(* Code that's being temporarily deactivated for testing purposes
IF Condition THEN
(*
Multi-line
comment in the wrong style
*)
//Multi-line
//comment in the right style
//statement that should not be active but is now
//because of wrong use of multi line comments
a := b;
END_IF;
*)