Formatting rules while coding HMG4
Posted: Tue Mar 29, 2011 1:53 pm
Didn´t find a specific topic about formatting rules while coding HMG4.
Please review what I found searching the forum:
1. Indentation is three spaces and not tab.
2. Variable names should start with the type (c,n,l,d,a,x,o,q as the case may be) as mentioned below in smaller case letter and name of the variable would start with an uppercase letter.
Examples:
cName - variable name 'cName' which is a character type.
nNumber - 'nNumber' variable which is a number type.
lYesNo - 'lYesNo' variable which is a logical type.
dToday - 'dToday' variable which is a date type.
aObjects - 'aObjects' variable which is an array type.
xValue - 'xValue' variable the type of which is not known now and may be known at run time.
oDataObject - 'oDataObject' variable which is an object type.
qPrinter - 'qPrinter' variable which is a QT object type.
3. When calling a QT method/function, the first word is started with a smaller case and next words are uppercase.
Example:
qTreeWidget:indexFromItem( qTreeWidgetItem )
4. A space is necessary between starting and ending parenthesis of function names and the parameters. Please see the example.
qTreeWidget.collapseItem(qTreeWidgetItem) - Wronge
qTreeWidget.collapseItem( qTreeWidgetItem ) - Right
5. All Harbour keywords must be uppercase: DO CASE IF ENDIF ELSE CASE FOR NEXT etc.
6. Only FUNCTION/METHOD Name must be starting at column 1, rest of the lines including RETURN
must be indented.
7. No short names as FUNC PROC be used, all complete ones.
8. SWTCH and DO CASE and its CASE statements must be on same indent:
...SWITCH x
...CASE 4
...CASE 5
...ENDSWITCH
9. Function call must be like: MyFunc( n, n1, ... ), no space between function name and opening parenthesis.
10. No comments starting with * (star). Only ANSI compatible // some comment OR preferably /* some comment */.
11. Every function body must be separated by a blank line and seperator. Seperator line must be uniform as I have used.
12. HMG library source must be compilable with -w3 switch. It helps to detect the wrong code soon.
13. No LOCAL variable assignment with NIL. It is neither needed not oprimized.
Please review what I found searching the forum:
1. Indentation is three spaces and not tab.
2. Variable names should start with the type (c,n,l,d,a,x,o,q as the case may be) as mentioned below in smaller case letter and name of the variable would start with an uppercase letter.
Examples:
cName - variable name 'cName' which is a character type.
nNumber - 'nNumber' variable which is a number type.
lYesNo - 'lYesNo' variable which is a logical type.
dToday - 'dToday' variable which is a date type.
aObjects - 'aObjects' variable which is an array type.
xValue - 'xValue' variable the type of which is not known now and may be known at run time.
oDataObject - 'oDataObject' variable which is an object type.
qPrinter - 'qPrinter' variable which is a QT object type.
3. When calling a QT method/function, the first word is started with a smaller case and next words are uppercase.
Example:
qTreeWidget:indexFromItem( qTreeWidgetItem )
4. A space is necessary between starting and ending parenthesis of function names and the parameters. Please see the example.
qTreeWidget.collapseItem(qTreeWidgetItem) - Wronge
qTreeWidget.collapseItem( qTreeWidgetItem ) - Right
5. All Harbour keywords must be uppercase: DO CASE IF ENDIF ELSE CASE FOR NEXT etc.
6. Only FUNCTION/METHOD Name must be starting at column 1, rest of the lines including RETURN
must be indented.
7. No short names as FUNC PROC be used, all complete ones.
8. SWTCH and DO CASE and its CASE statements must be on same indent:
...SWITCH x
...CASE 4
...CASE 5
...ENDSWITCH
9. Function call must be like: MyFunc( n, n1, ... ), no space between function name and opening parenthesis.
10. No comments starting with * (star). Only ANSI compatible // some comment OR preferably /* some comment */.
11. Every function body must be separated by a blank line and seperator. Seperator line must be uniform as I have used.
12. HMG library source must be compilable with -w3 switch. It helps to detect the wrong code soon.
13. No LOCAL variable assignment with NIL. It is neither needed not oprimized.