Code readability
When working with multiple developers on a single codebase and sharing software as open code with external partners, using a generic set of rules regarding readability is important from a maintenance perspective.
This includes a long list of small things such as using spaces, comments, white-lines, BEGIN
/END
, TRUE
/FALSE
, indentation, and parenthesis:
Spaces |
This keeps statements together when they belong together; add spaces only if readability becomes an issue:
IF NOT(Condition) THEN -NegativeValue Result := A / B; Complex := Calculate((A + B) + POWER(C)); Type = Type::Item: IF FIND('<>=') THEN |
Comments |
Add this only if required; comments should start directly after the code with a single space: ERROR(ThisIsWrongErr); // Show Error |
White lines |
Blank lines should only be used when they improve the readability of the function. Remember that adding a blank line is a good indication to break your function into multiple other functions... |