Scripting Best Practices

Variable Names

When considering variable names, we often default to “short and sweet” names rather than more expressive choices. Short names are useful as they do provide more space for Iguana’s annotation blocks. Alas, their brevity means that they have poor readability and cannot take full advantage of Iguana’s auto-completion tool.

General Rules

To help you design better variable names, follow these rules:

  • Use “Camel Case” for all variables
  • Type all constants in ALLCAPS
  • Choose intuitive names that are representive of the contents
  • Prepend Boolean variable with is (for example, use isValid rather than Valid)
  • Restrict the use of underscores as they can be confusing
  • Do not start names with underscores (internal Lua rule)
  • Only use single character variables for:
    • Counters (i)
    • Iterators (k,v)
    • Passed variables in short functions

Maximizing Auto-completion

To take full advantage of Iguana’s auto-completion tool, most variable names should be 4 to 8 characters in length.

If possible, prefix names with their logical “class” or “group”. For example, the variables name, number, and phone are quite easy to read and understand, but they are too generic and will not maximize auto-completion’s searching capability. By adding the prefix “pt” (representing “patient”), we create much more useful, meaningful names: ptName, ptNumber, and ptPhone. Now we can type “pt” and auto-completion will find these specific patient values instantly.

Tagged:

Leave A Comment?