Variable naming conventions
Today I came across an old document I created on June 2004 probably from some text I found on the internet or maybe from an old NUG post, to say the true I am not sure where it comes from. Anyway, the thing is that the document in question is some kind of variable naming conventions now I realize I fully adopted after reading it. This is what it recommends when naming things you are declaring in your code depending on their nature. For you to understand better, it is a list of heading characters you have to start names with. This is the list:
Local Variables: "a"
Global Variables: "g"
Constants: "k"
Input Parameters: "in"
Output Parameters: "out"
Input/Output Parameters: 'io"
Properites of Classes: "m"
Events: "ev"
Methods/Functions: descriptive name
Modules: DB_Module, System_Module
Methods/Functions in those modules: "DB_"
Properties in that module: "mDB_"
Constants in that module: "kDB_"
For example you would never use 'file' but 'aFile' if it is a local variable or 'gFile' if it is global. That simple.
I believe it is a really good idea to follow those rules, it makes the code easier to read and it makes really difficult for a variable to conflict with an existing keyword, a problem also known as "naming collision".
I even later use the same approach with SQL databases tables and fields.
Database Names: "db_"
Table Names: "tbl_"
Column/field Names: 'fld_"
Again, it makes the code more clear, easier to read and avoid the possibility of a conflict with an existing keyword. Example:
SELECT fld_name FROM tbl_customers
I recommend the use of those conventions. You will find more information soon this here.
—
Stan Busk - Software Engineer
at www.maxprog.com
Comments