Code Conventions

This is the general one of a serials articles cover different languages.

Bracket

Put opening bracket and closing bracket at same vertical position enabling easier visual check.

Comments

Since full stop/period merely used by any language as ending sign of a statement, it is suggested all comments are to be finished by full stop/period for readiability purpose.

Comparison of IF Statement

Put matched at the left hand side to avoid possible mistake of assignment. For instance:

; if ('String'==varA)

instead of:

; if (varA=='String')

IF ELSE Statement

If there is more than one set of conditions, please use following method to deal with the complex logics:

1. Employ a middle layer, say Action, between Conditions and Functions. Unlike Functions, Actions are just flags of Functions and some of them can override others.
2. Use several IF Statements instead of a single IF ELSE Statement to cover every situations selected by you.
3. Because some Actions may override others, so, careful arranging the orders of IF Statements is necessary.

For detail, please refer to IF ELSE Statement (http://koncordpartners.blogspot.com/2010/04/if-else-statement.html).

Indentation

Use of tabs should be avoided because there still is not a standard for the placement of tabstops. Different code editor will show it differently. The unit of indentation is two spaces, to enable indenting many levels.

No comments:

Post a Comment

Labels