Popular Variable Naming Conventions

Naming Conventions

Looking through various programmers’ code you may notice variables with different styles, I’m referring more to the use of lower and uppercase rather than how variable names are determined. Certain formatting of variable names indicate specific properties about that variable, mainly whether or not the variable is a constant or not but definitely others as well. It should be noted that while naming conventions are common to programmers, many languages have standard or at least largely accepted naming conventions so you should usually stick with the naming convention that is defined or more widely accepted by the language you are using.

The more common, standard naming conventions are as follows

  • Constants
    • UNDERSCORE_CASEĀ is a common naming convention for constants, any time you see this you can be fairly certain that this variable has a value that will never change. The idea is that all words are capitalized and each word is separated by an underscore.
  • Variables
    • camelCase is a common naming convention where every word in a variable name has the first letter capitalized with the exception of the first word.
    • TitleCase is another common naming convention although I tend to see it more in the higher level languages like Java and C#
    • _underscoreFirst is one that is more common in the lower level languages and typically indicates that the variable is private or has limited scope which I’ll talk about in another post.
    • underscore_variable is another one that is commonly found among the C family of languages.

There are definitely others that I have not listed here but these are some common conventions you will see in dealing with the C and C++ languages. More specifically I have highlighted in bold, the conventions you will most commonly see in the Arduino community.

Leave a Reply

Your email address will not be published. Required fields are marked *