Support

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
  How do I set up an unsubscribe link NEW Screenshot
  How to export several lists into to a single file NEW Screenshot
  Why do I get timeouts when testing given addresses NEW Screenshot
  What are the Zoho mail settings for MaxBulk Mailer? NEW Screenshot
  iCash has become slow over time NEW Screenshot
  Emails sent but not received NEW Screenshot
  Google ending support for less secure apps NEW YouTube Video
  HTML Email is received empty NEW Screenshot
  How to use an alternative text when a tag value is empty UPDATED Screenshot
  Email Bounce Handler no longer works with Gmail UPDATED Screenshot
  Is Maxprog software ready for the Apple ARM processor? UPDATED Screenshot
  Is Maxprog software prepared for Windows 11? UPDATED Screenshot
  Is Maxprog software prepared for macOS 12 Monterey? UPDATED Screenshot
  Mail rejected as SPAM Screenshot
  How do I enter turboSMTP settings into MaxBulk Mailer YouTube Video

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

▾ Last customer reviews ▾


Did you like this post?


🔐 Site secured by Comodo SSL
🟢 UptimeRobot - Site Loaded properly