A first pass at some conventions and standards for the project. Could everyone please respond with agreement or disagreement by the item number on left by June 20?
Indenting.
1-- to 4-space boundaries please.
Declaring Variables
2-- At the top of the SUB or FUNCTION. not inline.
Underscore
3-- Could we make use of this for line continuation and file names only.(not in variable or function names)
Variable naming
4a-- "modified Hungarian Notation"
b-- meaningful names, don't be afraid to comment if possibly confusing
c-- data type prepended to meaningful name made up of words with initial letter capitalized.
d-- p prepended to that for pointers
eg:
local dwSQLiteArrayAddress as dword
local pszQueryResults() as asciz ptr
redim pszQueryResults(0 to lmax) at dwSQLiteArrayAddress
Exception
5-- variables used in obvious situation where the context is clear
eg: loop counters, etc.
Globals
Chris>>
6-- Having skimmed Stan's ToDoList, I also picked up an item "Use of Global Vars" under "Coding Conventions". This is one that deserves to be expanded into "Use of Global and Static variables as an alternative to dynamic memory allocation".
In my opinion, the use of Globals etc should be kept to a minimum and a reasonable case made for the use of globals at peer review level - in other words, although they are to be avoided, I don't think that they are inexcusable. An exception would be when writing a small supporting application, in which case, who cares.
<<
While there is a school of thought that thinks, believes, demands Globals should be avoided at all costs, I am not a member of that school.Admittedly, a project of this size might give me pause. However, Globals are a tool in the toolbox. I too, urge judicious use.
FUNCTION names
7a-- Meaningful (in English).
b-- parameters listed one per line with line continuation character(underscore) to leave room for verbose(if needed) comments.
c-- Immediately following parameters a description of the function's purpose. I also suggest programmer's initials and date. All commented out, of course.
d-- Use visual separators
FUNCTION prototypes
- I'm off the beaten track here. I only use them for exposed functions. <<Chris
8-- Other functions are ordered in the source code so that prototypes are not essential to compilation. <<Chris me too
FILES
VB source files
9a-- Begin all filenames with VB_
b-- Use VB standard extensions
eg:
VB_testgrphx.frm
c-- I'm not so sure that the VB source files have to be named in stringent fashion, unless they are files produced expressly for this project.
PB source files
10a-- Begin all filenames with PB_vb2pb_
b-- Include concise descriptive term up to 8 letters PB_vb2pb_whatever.
c-- Include date of submission in name PB_vb2pb_YYYYMMDD ( Use the YYYYMMDD format so the highest number is always the latest)
d-- Include Programmer's Initials as last two characters of filename
e-- Use extensions as supplied by the PB IDE.
I suggest the date and programmer information because at this early stage I already have four different files named vb2pb.bas on my computer.
Generated source files.
11a-- For the project purposes that the converter generate a name that include the date in the above format followed by an underscore character and then some identification of the version iteration.
b-- That the release version of the CONVERTER defaults to the name of the VB source, with an option to change as the user sees fit.
c-- I have not broached the subjects of DLLs, INCs, or Resource files at this time, still open to suggestions.
Document files
12-- All documents (.doc, .rtf, etc.) also in .txt format.
chris>>
One good convention is to document interfaces most carefully, then explain them again. I would treat any exposed function calls as interfaces. Because of PowerBASIC's range of types, it is worth being very careful with 32-bit values, which deserve not only carefully crafted names, but sufficient description to remove any ambiguity altogether.
<< (edited)
As in life, low standards makes for regrets, but high standards makes for slow work.<<Chris
Some of these things may need more depth, but we need feedback to make this as smooth as it should be.
Slightly off topic, but should we keep a list of items to be passed to PB somewhere along the way? These would fall in the category of NFSs, things that might make projects like this even easier.
Rod
Indenting.
1-- to 4-space boundaries please.
Declaring Variables
2-- At the top of the SUB or FUNCTION. not inline.
Underscore
3-- Could we make use of this for line continuation and file names only.(not in variable or function names)
Variable naming
4a-- "modified Hungarian Notation"
b-- meaningful names, don't be afraid to comment if possibly confusing
c-- data type prepended to meaningful name made up of words with initial letter capitalized.
d-- p prepended to that for pointers
eg:
local dwSQLiteArrayAddress as dword
local pszQueryResults() as asciz ptr
redim pszQueryResults(0 to lmax) at dwSQLiteArrayAddress
Exception
5-- variables used in obvious situation where the context is clear
eg: loop counters, etc.
Globals
Chris>>
6-- Having skimmed Stan's ToDoList, I also picked up an item "Use of Global Vars" under "Coding Conventions". This is one that deserves to be expanded into "Use of Global and Static variables as an alternative to dynamic memory allocation".
In my opinion, the use of Globals etc should be kept to a minimum and a reasonable case made for the use of globals at peer review level - in other words, although they are to be avoided, I don't think that they are inexcusable. An exception would be when writing a small supporting application, in which case, who cares.
<<
While there is a school of thought that thinks, believes, demands Globals should be avoided at all costs, I am not a member of that school.Admittedly, a project of this size might give me pause. However, Globals are a tool in the toolbox. I too, urge judicious use.
FUNCTION names
7a-- Meaningful (in English).
b-- parameters listed one per line with line continuation character(underscore) to leave room for verbose(if needed) comments.
c-- Immediately following parameters a description of the function's purpose. I also suggest programmer's initials and date. All commented out, of course.
d-- Use visual separators
FUNCTION prototypes
- I'm off the beaten track here. I only use them for exposed functions. <<Chris
8-- Other functions are ordered in the source code so that prototypes are not essential to compilation. <<Chris me too
FILES
VB source files
9a-- Begin all filenames with VB_
b-- Use VB standard extensions
eg:
VB_testgrphx.frm
c-- I'm not so sure that the VB source files have to be named in stringent fashion, unless they are files produced expressly for this project.
PB source files
10a-- Begin all filenames with PB_vb2pb_
b-- Include concise descriptive term up to 8 letters PB_vb2pb_whatever.
c-- Include date of submission in name PB_vb2pb_YYYYMMDD ( Use the YYYYMMDD format so the highest number is always the latest)
d-- Include Programmer's Initials as last two characters of filename
e-- Use extensions as supplied by the PB IDE.
I suggest the date and programmer information because at this early stage I already have four different files named vb2pb.bas on my computer.
Generated source files.
11a-- For the project purposes that the converter generate a name that include the date in the above format followed by an underscore character and then some identification of the version iteration.
b-- That the release version of the CONVERTER defaults to the name of the VB source, with an option to change as the user sees fit.
c-- I have not broached the subjects of DLLs, INCs, or Resource files at this time, still open to suggestions.
Document files
12-- All documents (.doc, .rtf, etc.) also in .txt format.
chris>>
One good convention is to document interfaces most carefully, then explain them again. I would treat any exposed function calls as interfaces. Because of PowerBASIC's range of types, it is worth being very careful with 32-bit values, which deserve not only carefully crafted names, but sufficient description to remove any ambiguity altogether.
<< (edited)
As in life, low standards makes for regrets, but high standards makes for slow work.<<Chris
Some of these things may need more depth, but we need feedback to make this as smooth as it should be.
Slightly off topic, but should we keep a list of items to be passed to PB somewhere along the way? These would fall in the category of NFSs, things that might make projects like this even easier.
Rod
Comment