Home Products Downloads News Store Support

Stan's Blog

Variable naming conventions

How to use Maxprog products Maxprog's Blog

Compatible with MS Windows Compatible with MacOS


Variable naming conventions

Topics

Today I came across an old document I created in June 2004 probably from some text I found on the internet or maybe from an old Xojo Forum post, to say the truth 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 it 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.


Recent questions from our users
  Why the iCash transaction amount column has disappeared Screenshot
  451 Error code Screenshot
  Problem sending email to Gmail recipients Screenshot
  What is the meaning of the recipient panel icons Screenshot
  How to create new projects in iCash Screenshot
  How to add transactions to iCash faster YouTube Video
  What is the best mail server I can use with MaxBulk Mailer Screenshot
  How can I export my lists to a new computer Screenshot
  How to send a HTML email Screenshot
  How to hide text in my message Screenshot
  How to transfer FTP accounts between computers Screenshot
  Google ending support for less secure apps YouTube Video
  How to add social networks icons to my message Screenshot
  How do I set up an unsubscribe link Screenshot
  How to export several lists into to a single file Screenshot

▾ Last videos, Online events and Q&A Sessions ▾
▾ Last customer reviews ▾


🔐 Secured by Sectigo SSL | UptimeRobot - Site Loaded properly