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


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
  How to transfer FTP accounts between computers NEW Screenshot
  Google ending support for less secure apps UPDATED 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
  Why do I get timeouts when testing given addresses Screenshot
  What are the Zoho mail settings for MaxBulk Mailer? Screenshot
  iCash has become slow over time Screenshot
  Emails sent but not received Screenshot
  HTML Email is received empty Screenshot
  How to use an alternative text when a tag value is empty Screenshot
  Email Bounce Handler no longer works with Gmail Screenshot
  Is Maxprog software ready for the Apple ARM processor? Screenshot
  Is Maxprog software prepared for Windows 11? Screenshot
  Is Maxprog software prepared for macOS 12 Monterey? Screenshot

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

▾ Last customer reviews ▾

Did you like this post?

🔐 Secured by Comodo SSL | UptimeRobot - Site Loaded properly