This paper will describe the variable naming rules of three different programming languages. These three languages are Visual Basic, Python, and Java. Each of these languages has different rules that apply to them and some similarities. I will describe the rules and the similarities and differences in the next few paragraphs.
The first language and its rules I will describe is Visual Basic. Visual Basic has a few different rules and they are described on Microsoft’s website in a document. This document is called (“Visual Basic Naming Rules”) and they read as such: You must use a letter as the first character.
You can’t use a space, period (.), exclamation mark (!), or the characters @, &, $, # in the name. Name can’t exceed 255 characters in length.
Generally, you shouldn’t use any names that are the same as the functions, statements, and methods in Visual Basic. Visual Basic isn’t case-sensitive, but it preserves the capitalization in the statement where the name is declared. These are the variable naming rules are specific to Visual Basic and are essential to know if you program using Visual Basic.
The second language I will describe is Python. This language has a few rules of its own and they are described on a site called programmr.com in an article called (“Python Variable Naming Rules”) and they read as such: Must begin with a letter (a – z, A – B) or underscore (_). Other characters can be letters, numbers or _ only. Variable names are Case Sensitive.
There are some reserved words which we cannot use as a variable name because Python uses them for other things. These are: and, del, from, not, while, as, elif, global, or, with, assert, else, if, pass, yield, break, except, import, print, break, except, import, print, class, exec, in, raise, class, exec, in, raise, continue, finally, is, return, continue, finally, is, return, def, for, lambda and try. These are the naming rules for Python and are necessary to programming in this specific language.
The third and final language I will talk about is Java. This program is no different than the other two languages and its rules are described in an Oracle document called (“Lesson: Language Basics”) in a sub article called “Variables” and they read as such: Variable names are case-sensitive. A variable’s name can be any legal identifier — an unlimited-length sequence of Unicode letters and digits, beginning with a letter, the dollar sign “$”, or the underscore character “_”. The convention, however, is to always begin your variable names with a letter, not “$” or “_”. Additionally, the dollar sign character, by convention, is never used at all.
You may find some situations where auto-generated names will contain the dollar sign, but your variable names should always avoid using it. A similar convention exists for the underscore character; while it’s technically legal to begin your variable’s name with “_”, this practice is discouraged. White space is not permitted. Subsequent characters may be letters, digits, dollar signs, or underscore characters. Conventions (and common sense) apply to this rule as well.
When choosing a name for your variables, use full words instead of cryptic abbreviations. Doing so will make your code easier to read and understand. In many cases it will also make your code self-documenting; fields named cadence, speed, and gear, for example, are much more intuitive than abbreviated versions, such as s, c, and g. Also keep in mind that the name you choose must not be a keyword or reserved word. If the name you choose
If your variable stores a constant value, such as static final int NUM_GEARS = 6, the convention changes slightly, capitalizing every letter and separating subsequent words with the underscore character. By convention, the underscore character is never used elsewhere. The Java programming language is statically-typed, which means that all variables must first be declared before they can be used.